• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 812
  • Last Modified:

Trouble executing shell command from .vbs for backup

If I run:
c:\windows\system32\ntbackup.exe backup "@C:\File of Disinterest.bks" /n "Monthly Archive created 2008-02-06 at 20`05" /d "Monthly Archive created 2008-02-06 at 20`05" /v:yes /r:no /rs:no /hc:off /m normal /j "Monthly Archival" /l:f /f "X:\Rossamino backup$\Monthly Archive 2008-02-06.bkf" /SNAP:on
from a DOS prompt, it works just fine.  When I run it from .VBS as:
    set wshell = Wscript.crateObject("Wscript.Shell")
    wshell.run "command.com /c " & runstring
where runstring is equal to the command it won't work.  It also won't work if I insert the command in place of runstring and many iterations thereof.

Is there a maximum number of arguments that can be passed with the wshell.run method thingy?
0
Rossamino
Asked:
Rossamino
  • 2
1 Solution
 
Rog DManager Inforamtion SystemsCommented:
You may want to put a breakpoint on the wshell.run statment and get the exact string that is being run, then paste that string on the Run in dos and see what is there?

If it works then I would look further into the wshell.run command in vbs.

Rog
0
 
Rog DManager Inforamtion SystemsCommented:
Check this link out....

http://weblogs.asp.net/steveschofield/archive/2004/03/14/89240.aspx

They discuss some wshell stuff.  Including some discussion on the double quote and other things too....  This maybe your problem. or it may give you some more ideas of where to look too.

Rog
0
 
RobSampsonCommented:
No, there is not limit, except for any limit that may be imposed by the program you're running.  The catch, though, is that you need to double your quotes when inserting it into a VBS string, so, without testing it this should work:

'===============
Set objShell = CreateObject("WScript.Shell")
strCommand = "ntbackup.exe backup ""@C:\File of Disinterest.bks"" " & _
      "/n ""Monthly Archive created 2008-02-06 at 20-05"" " & _
      "/d ""Monthly Archive created 2008-02-06 at 20-05"" " & _
      "/v:yes /r:no /rs:no /hc:off /m normal /j ""Monthly Archival"" " & _
      "/l:f /f ""X:\Rossamino backup$\Monthly Archive 2008-02-06.bkf"" /SNAP:on"
strCommand = InputBox("The command to be run is below. You can test it " & _
      "by copying the text into a Start --> Run box.", "Command to Run", strCommand
strResponse = MsgBox("Do you want to run this command?" & VbCrLf & strCommand, _
      vbYesNo, "Run Command?")
If strResponse = vbYes Then
      objShell.Run strCommand, 1, True
      MsgBox "Finished."
Else
      MsgBox "Command cancelled."
End If
'===============

Regards,

Rob.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now