Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple command line arguments? 3

Status
Not open for further replies.

unclerico

IS-IT--Management
Jun 8, 2005
2,738
US
I am trying to convert the following .bat file into a .vbs file but I am unsure of the easiest way:
Code:
D:
cd .\RightFax\AdmUtils
faxdump -fserver.domain.com -uDEFAULT -s10/01/05 -e10/31/05 -oC:\Temp\Fax.txt -l1 -h
Now I know how to use the WScript.Shell with the Run method but how do I specify all 4 of the above lines of code in a single command?
Code:
Dim WshShell

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "D:"
WScript.SendKeys "{ENTER}"
WshShell.Run "cd .\RightFax\AdmUtils"
WScript.SendKeys "{ENTER}"
WshShell.Run "faxdump -fserver.domain.com -uDEFAULT -s10/01/05 -e10/31/05 -oC:\Temp\Fax.txt -l1 -h"
WScript.SendKeys "{ENTER}"
This just seems like way too many lines of code to do what I need. Any help would be awesome.
 
Perhaps something like this ?
WshShell.Run "CMD /c D: & cd .\RightFax\AdmUtils & faxdump -fserver.domain.com -uDEFAULT -s10/01/05 -e10/31/05 -oC:\Temp\Fax.txt -l1 -h"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
the syntax for executing multiple shell commands is &&
so..

cmd /c d: && cd test1\testfolder && pkunzip.exe...
 
I do not see that it needs to be multiple lines. It appears that the batch file just changes to where the program is located to run it. The batch file looks like it could even have been written as a single line by just putting "D:\RightFax\AdmUtils\" in front of the faxdump. Also the SendKeys is not needed. Multiple calls to WshShell.Run do not have the effect you think. Each is a completely separate process.

The first one opens an explorer window on drive D:. The second one would probably open a command prompt that would attempt to change to that directory relative to your home directory. That would probably fail and then exit the command prompt. The third one would then attempt to run faxdump but if it is not in the path would probably also fail.

Your vbs could be only 2 lines.
Code:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "D:\RightFax\AdmUtils\faxdump -fserver.domain.com -uDEFAULT -s10/01/05 -e10/31/05 -oC:\Temp\Fax.txt -l1 -h"

While it may be good practice to always Dim your variables, on a 2 line script it is not needed.
 
all depends on what you are trying to run i would say.
i have come across lots of different applications whcih do not like to be run unless the Shells current folder is where they are located. bad coding, old coding call it what you like some exe's just dont like it.
 
wshshell supports now/then currentdirectory, so one could spare that part of the multiple.
[tt] wshshell.currentdirectory="d:\rightfax\admutils"
[/tt]
 
thanks tsuji, dont know why i didnt spot that sooner
 
hmm , i know why i didnt spot it, its not in the helpfile i have for WSH!
 
Man you guys rock, thanks a lot for the responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top