Using wshell to run a .bat file
Posted on 2006-06-04
I've looked through the various topics on this, and have tried these two pieces of code, both without success:
Dim wshell, proc
set wshell = server.createobject("wscript.shell")
set proc = wshell.exec("%comspec% /c 7za a -tzip XNWFRA_5JUN20065953.zip XNWFRA_5JUN20065953.xml @listfile.txt", 0, True)
This is the error I get on the last line above:
Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'exec'
/TestZip.asp, line 7
Please note, the part of the line that reads thus:
7za a -tzip XNWFRA_5JUN20065953.zip XNWFRA_5JUN20065953.xml @listfile.txt
is the commands required to zip up a set of files using 7zip a command line zip utility.
Now, when I have that line inside a .bat file and execute the .bat file "manually" on the webserver, it does exactly what it is meant to do.
The other way I have tried to do this is using the following code:
set wshell = Server.CreateObject("WScript.Shell")
set wshell = nothing
Nothing happens, and I get no error.
I have given IUSR_ full permissions on the folder containing the batch file.
If someone could help me, I woul dbe most obliged!