views:

153

answers:

2

How can I execute two consecutive commands on the command line with the help of wshshell.exec or wshshell.run in vbscript? For example I need to execute cd C:\a and then winzip32.exe -min -a D:\a.

+1  A: 

You can do something like cd C:\a & winzip32.exe -min -a D:\a where the & separates commands so the that second one runs once the first has finished successfully. For example, you could run it like this:

Set oExec = WshShell.Exec("cmd /c cd C:\a & winzip32.exe -min -a D:\a")

Without the cmd /c in the beginning, you can't do things like cd because it is cmd.exe that processes the cd and &.

Gabe
sushant
sorry i dont know how to format it
sushant
Where are you using that HTML? In a HTA or a normal web page? Just wondering cause normally WshShell cannot be created in a web page as it is considered unsafe.
tyranid
you r a life saver. thanks a looooooooooot :)
sushant
A: 

Depending on what you're doing, you could use WshShell.Exec "c:\a\winzip32.exe -min -a D:\a"

leereid