Zipping a folder using 7-Zip from an asp page - asp-classic

I am trying to zip a folder from an asp page. This is my code:
zipFolderName=folderName &"Zipped.zip"
command="cd C:\Program Files\7-Zip & "
command = command & "7z a -tzip " & zipFolderName & " """ & folderName & """"
Response.Write command
set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing
The command that is written in the Response.Write is
cd C:\Program Files\7-Zip & 7z a -tzip D:/saveAll/DocumentsZipped.zip "D:/saveAll/Documents"
When I run this command in a cmd window it works just fine. But my asp page shows an error:
WshShell.Exec error '80070002'
The system cannot find the file specified.
The error is on the objShell.exe command-line.
What am I doing wrong? Please help!

You need to put C:\Program Files\7-Zip between double quotes, because the path contains a space. Also, cd and & are CMD-builtins, so you need to run the command line in CMD.
Change this:
command="cd C:\Program Files\7-Zip & "
into this:
command = "%COMSPEC% /c cd ""C:\Program Files\7-Zip"" & "

Related

How to launch .exe file with run

I tried to launch a program with Run & Runwait but the program don't appear
Run & Runwait command
Run('R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\scrcpy-noconsole.exe')
Or
Run('#Scriptdir\lib\scrcpy-win64\scrcpy-noconsole.exe')
same with runwait
No error messages
Try setting the working dir for the program.
Run('R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\scrcpy-noconsole.exe', 'R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\')
And if you are using #ScriptDir it should go like this:
Run(#Scriptdir & '\lib\scrcpy-win64\scrcpy-noconsole.exe', 'R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\')

How to run nswag code generating script on MacOS

I'm trying to run a code generating script from terminal within vs code on a mac, but each time I get the the following error:
cmd: "..\node_modules\.bin\nswag" run
cmd : The term 'cmd' is not recognized as the name of a cmdlet,
function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.
At ...
here's the ps1 script I was trying to run:
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
Set-Location $directorypath
$cmdString = """" + "..\node_modules\.bin\nswag" + """" + " run";
Write-Host 'cmd:' $cmdString
cmd /c $cmdString

Autoit launches batchfile passing variable

I'm currently trying to create an installation tool. I have a a batch file calling some sqlcmd commands and I'd like to trigger it from Autoit. It works.
Now, I'd like to set a variable in Autoit (by getting it from a GUI) and pass it to the batch file when calling it. It should be something like this :
RunWait('path_of_file\mybat.bat' & %myVar%)
I read a lot from the Autoit community without finding the answer. I got things like :
RunWait('path_of_file\mybat.bat' & " " & $myVar) <- This solution didn't work for me
or
RunWait(#ComSpec & " /k "...) <- This one didn't suit what I'd like to do, as I'm
launching a batchfile and not a cmd command.
If anyone has an idea !
Thanks in advance :)
This should work:
Autoit works
Local $myVar = "ipconfig"
RunWait('mybat.bat ' & $myVar)
Autoit works too
ShellExecute("mybat.bat", $myVar)
mybat.bat
#echo off
echo %1
%1
ping 127.0.0.1 -n 6 > nul

Why cant I run my application with a default file like that of notepad?

Why cant I run my application with a default file like that of Notepad ?
AutoIt sample code below :
Example()
Func Example()
; Run Notepad
Run("Notepad.exe " & "C:\Users\judith_francis\Desktop\dd.txt")
Run("C:\Program Files (x86)\abc\abc.exe" & "C:\Users\xyz\Desktop\test_image.tif")
EndFunc
This line:
Run("C:\Program Files (x86)\abc\abc.exe" & "C:\Users\xyz\Desktop\test_image.tif")
Runs the command
C:\Program Files (x86)\abc\abc.exeC:\Users\xyz\Desktop\test_image.tif
Which Windows will interpret as
C:\Program
Try instead
Run('"C:\Program Files (x86)\abc\abc.exe" ' & '"C:\Users\xyz\Desktop\test_image.tif"')
Which adds the necessary space & quotes & will be executed as
"C:\Program Files (x86)\abc\abc.exe" "C:\Users\xyz\Desktop\test_image.tif"

Why does SendKeys produce an error in Windows 7?

I am trying to run this code:
SendKeys "copy /b /y " & outputfile & " " & printerid & "{Enter}", 1.
It runs fine in Windows XP but in Windows 7 it gives an error.
I am trying to copy a string into cmd and execute it.
The "{Enter}" part is giving error.
Please help.
A quick test on Windows 7 gives me:
'sendkeys' is not recognized as an internal or external command,
operable program or batch file.
If that's the same error that you're getting, it means you don't have the program. Try copying it over from XP and see if that works.
If you've already copied it, it might not be in your PATH. Try this:
set PATH=%PATH%;C:\Path\to\SendKeys\
where C:\Path\to\SendKeys is the folder that contains SendKeys.exe.

Resources