james_tubberville
asked on
Run cmd line from vbs
I'm trying to run a command line program with a user provided switch using vbs (command with userid as switch. I have copied the problem portion of the script and several variations below.
strUserID = Inputbox("Enter USER ID","USERID","EX: LastFM")
If strUser = "" Then
WScript.Quit
End If
strCmdLine = "C:\Progra~1\ARPR\arw00\ar w00 " & strUserID
set WshShell = CreateObject("WScript.Shel l")
WshShell.Run"cmd.exe /c" & strCmdLine,1,TRUE
also tried
strCmdLine = "C:\Progra~1\ARPR\arw00\ar w00 "
set WshShell = CreateObject("WScript.Shel l")
WshShell.Run"cmd.exe /c" & strCmdLine & strUserID,1,TRUE
and also
set objShell = wscript.createObject("wscr ipt.shell" )
objShell.Run("cmd.exe /c" & "C:\Progra~1\ARPR\arw00\ar w00 " & strUserID, 1, TRUE)
I been working on several long scripts for the past two weeks and this simple task (one of those 30 second scirpts) is driving me crazy...I believe my brian is done for the month!
What am I overlooking? Assigning 500 due to need not difficulty!!!
strUserID = Inputbox("Enter USER ID","USERID","EX: LastFM")
If strUser = "" Then
WScript.Quit
End If
strCmdLine = "C:\Progra~1\ARPR\arw00\ar
set WshShell = CreateObject("WScript.Shel
WshShell.Run"cmd.exe /c" & strCmdLine,1,TRUE
also tried
strCmdLine = "C:\Progra~1\ARPR\arw00\ar
set WshShell = CreateObject("WScript.Shel
WshShell.Run"cmd.exe /c" & strCmdLine & strUserID,1,TRUE
and also
set objShell = wscript.createObject("wscr
objShell.Run("cmd.exe /c" & "C:\Progra~1\ARPR\arw00\ar
I been working on several long scripts for the past two weeks and this simple task (one of those 30 second scirpts) is driving me crazy...I believe my brian is done for the month!
What am I overlooking? Assigning 500 due to need not difficulty!!!
WshShell.Run "cmd.exe /c" & chr(34) & strCmdLine & strUserID & chr(34),1,TRUE
ASKER
Clarification:
Program opens as follows
arw00 userid
running batch containing arw00 %username% works for a local user
The program is designed not to open in windows (database error occurs)
Using an inputbox in vbs to provide userid i need the vbs script to run as if running a command line
Program opens as follows
arw00 userid
running batch containing arw00 %username% works for a local user
The program is designed not to open in windows (database error occurs)
Using an inputbox in vbs to provide userid i need the vbs script to run as if running a command line
WshShell.Run will execute the program as if executed from a command line, so I don't understand your last post.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've never had the problem with WshShell.Run not executing as it should. WShell.Exec executed the program including the switch as the database delimiter.
cmd.exe /c"c:\...\program parameter"
It's probably not working correctly because it sees it as cmd.exe /cc:\...\program parameter
which then parameter is passed to cmd.exe not c:\...\program.