Announcement

Collapse
No announcement yet.

obj.shell help

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • obj.shell help

    I can't seem to get the right way to put two commands in one line of obj.shell, I think my quotations are right, but the errors are pointing to where I try to continue the code onto the next line:

    Code:
    Set objShell = CreateObject("Wscript.Shell")
    
    strSession = InputBox("Enter the session to restore:")
    strRestorePath = BrowseForFolder("Choose the Restore Path:", &H4031, &H0011)
    strTarget = InputBox("Enter the target computer name to redirect to:")
    
    objShell.Run("""%comspec% /K cd C:\Program Files\OmniBack\bin |omnir & _
    		-winfs server.domain-server.com:/H ""H:""  & _
    		-session ""strSession"" -tree ""strRestorePath""  -target ""strTarget""  & _
    		-as /tmp"""), 0, True
    
    Set objShell = Nothing

  • #2
    Re: obj.shell help

    Its a bit tricky when using shell.run, the whole command must between quotes. But when you add a break in the line you must first close the actual quote then add '& _' . Starting the new line with a quote. Another thing is when you have to use quotations within quotations. For the quotations you use in the actual command-line replace these with & chr(34) &.
    http://www.google.com/search?q=doubl...er%2Fresources
    http://www.google.com/search?q=objSh...er%2Fresources

    A good practice is to set parameters in advance;
    someting like this:
    Code:
    Set objShell = CreateObject("Wscript.Shell")
    
    sBoxTitle = "Results OMNIR"
    'http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0826.mspx
    
    'cumulative command-line building
    strCommand = "%comspec% /T:84 /K title " & sBoxTitle & "|"
    strCommand = strCommand & chr(34) & "C:\Program Files\OmniBack\bin\omnir.exe" & chr(34)
    strCommand = strCommand & " -winfs server.domain-server.com:/H " &chr(34) _
                                                       & "H:" & chr(34)
    strCommand = strCommand & " -session " &chr(34) & "strSession" &chr(34)
    strCommand = strCommand & " -tree " &chr(34) & "strRestorePath" &chr(34)
    strCommand = strCommand & " -target " &chr(34)& "strTarget" & chr(34)
    strCommand = strCommand & " -as /tmp"
    
    wscript.echo strCommand  ' <---temporarily (to test if the command line is correct)
    
    objShell.Run(strCommand)
    
    Set objShell = Nothing
    EDIT:
    now the dos-box is left open after the command



    \Rem
    Last edited by Rems; 6th March 2007, 13:41. Reason: program path must also be between quotes, done

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: obj.shell help

      Ahhh I see, thank you this will be very useful.

      Comment

      Working...
      X