Results 1 to 4 of 4

Thread: VBS Run command - help required

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    VBS Run command - help required

    Hello everyone,
    I'm trying to run following CMD command using VBS Run.

    Exe file is under directory: c:\Program Files\O T A\ota.exe

    CMD:

    c:\cd Program Files
    c:\Program Files\cd O A T
    c:\Program Files\O A T\oat.exe /Auto /T:A /AP:20020303-20020403A /DA:"xxxx" /SA:"yyyy" /Unread:Y


    VBS:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run ("CMD /K ""c:\Program Files\O A T\oat.exe""" & "/Auto /T:A /AP:20020303-20020403A /DA:""xxxx"" /SA:""yyyy"" /Unread:Y")

    From my own thoughts there are problems with quotes which appearing in parameters of the program.

    Unfortunately I'm getting error: 'C:\Program' is not recognised as an internal or external command, operable program or batch file.

    Thanks in advance for help.

    Regards,
    Wojciech

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: VBS Run command - help required

    Does this work?
    Code:
    Dim WshShell
    Dim sPath, sParams
    
    	sPath = Chr(34) & "c:\Program Files\O A T\oat.exe" & Chr(34)
    	sParams = " /Auto /T:A /AP:20020303-20020403A /DA:" & Chr(34) & "xxxx" & Chr(34) & " /SA:" & Chr(34) & "yyyy" & Chr(34) & " /Unread:Y"	
    
    	Set WshShell = WScript.CreateObject("WScript.Shell")
    	WshShell.Run ("CMD /K " & sPath & sParams)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    Re: VBS Run command - help required

    Unfortunately not, It gave exactly same error.

    Regards,
    Emacs

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    Re: VBS Run command - help required

    OK I work around this using bat file. If someone will have same problem below is a sample code.

    Code:
    Dim strBat1, strBat2, batFile, fso
    
    strUser = "KimK"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set batFile = fso.CreateTextFile("battest.bat",True)
    
    strBat1 = "cd /D C:\Program Files\O T A"
    strBat2 = "START OTA.exe /Auto /T:A /AP:20080101-20080630A /SA:""" & strUser & _
    			""" /DA:""" &  strUser & "_2008_Jan-Jun""" &  " /Unread:Y"
    
    batFile.WriteLine strBat1
    batFile.WriteLine strBat2
    batFile.Write
    
    batFile.Close
    
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run ("CMD /K ""C:\Program Files\O T A\battest.bat""")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width