Announcement

Collapse
No announcement yet.

run batch file from vbs script

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

  • run batch file from vbs script

    How would I run a .bat file from a vbs script?

  • #2
    Re: run batch file from vbs script

    Have you tried : http://www.google.co.il/search?hl=iw...from+vbs&meta= ?
    Here's a example (from the second link):
    Code:
    Running DOS Batch File with Shell using vbscript through VBS script 
    
    
    'Code by Kiran 
    'Running DOS Batch File with Shell using vbscript through VBS script
    'You can run Batch file from Visual Basic Exe or with siple text file called VBS file
    'Type below code in note pad and save it with .VBS extension,
    'Once you double click this it aoutomatically exicutes the DO Batch file
    
    Set oShell = CreateObject("WSCript.shell") 
    
    sCmd = "C:\yourbatchfile.bat"
    
    ' If you have spaces in the path, you can do like this instead:
    'sCmd = Chr(34) & "j:\yourbatchfile.bat" & Chr(34) 'commented 
    
    ' The 0 will make it run hidden
    oShell.Run sCmd, 0, False
    
    ' The 7 will make it run minimized
    'oShell.Run sCmd, 7, False 'commented

    Sorin Solomon


    In order to succeed, your desire for success should be greater than your fear of failure.
    -

    Comment


    • #3
      Re: run batch file from vbs script

      I have tried that but nothing happens with I run the script. It does not create the file that the batch file should.

      Comment


      • #4
        Re: run batch file from vbs script

        This is the right way to do it:

        Code:
        Set objShell = WScript.CreateObject("WScript.Shell")
        objShell.Run("%comspec% /K Script.bat"), 1, True

        Comment

        Working...
        X