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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running a command in VBScript 3

Status
Not open for further replies.

dseaver

IS-IT--Management
Jul 13, 2006
467
I create command string using the following
Code:
Dim LogFileName
LogFileName =  "C:\Logs\RestoreLog-" & Replace(date(), "/", "_") &".txt"
Dim CommandStr
CommandStr = """C:\program files\acronis\trueimageworkstation\trueimagecmd.exe"" /filerestore /filename:""E:\Backup.tib"" >" & LogFileName & " 2>&1"

When I run the resulting string in cmd.exe, it creates the log file, but when its run using

Code:
Set MyObj=CreateObject("WScript.Shell")
MyObj.Run CommandStr

The log file is not generated. any ideas how to fix this?
 
What is the code exhibiting the behaviour posted 7 Nov 07 8:46 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
sExePath = "C:\program files\acronis\trueimageworkstation\trueimagecmd.exe"
sSwitches = "/filerestore /filename:E:\Backup.tib >> """ & LogFileName & """ 2>&1"
If objFSO.FileExists(sExePath) Then
objShell.Run "%comspec% /k """ & sExePath & _
""" " & sSwitches, 2, True

Is the code for 7 Nov 07 8:46
 
sExePath = "C:\program files\acronis\trueimageworkstation\trueimagecmd.exe"
sSwitches = "/filerestore /filename:E:\Backup.tib >> " & LogFileName & " 2>&1"

If objFSO.FileExists(sExePath) Then
objShell.Run "%comspec% /c """ & sExePath & _
""" " & sSwitches, 2, True


^^^Works!! Thanks all for your help!!
 
Now, If I understand correctly, When I call that command, the script will carry while this happens elsewhere, correct? Is there a way for me to wait until this, or similar, commands are done before continuing on?
 
Read the comments included with my orginal code.

the true at the and of the .run command causes the script to wait for the run to finish then continue. False would cause it to continue on while the cammand that was called with the run is doing it's thing.

Thanks

John Fuhrman
Titan Global Services
faq329-6766
 
Thanks again, after I looked at the code, I realized that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top