1

I am try to run the go.bat from VB but when I run the script I get: :cant find specific file

but from the cmd window the file go.bat exist. what the problem?

Dim MyShell

Dim shell_cmd

  shell_cmd = "C:\Program Files\dir1\dir2\wizard\go.bat"

  set MyShell = CreateObject("WScript.Shell")

  MyShell.Run shell_cmd, 1, 1

from cmd window

C:\Program Files\dir1\dir2\wizard>go.bat
Dhinakar
  • 4,061
  • 6
  • 36
  • 68
yael
  • 2,765
  • 10
  • 40
  • 48

2 Answers2

3

Your batch file's full path contains spaces, so you need to enclose it in double quotes, like this:

shell_cmd = """C:\Program Files\dir1\dir2\wizard\go.bat"""

or

shell_cmd = Chr(34) & "C:\Program Files\dir1\dir2\wizard\go.bat" & Chr(34)
Helen
  • 87,344
  • 17
  • 243
  • 314
0

not sure if you knew but in vb you can use the Shell function:

http://msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx

(seems easier than what you're using)

I don't know why you get this message, but the two paths you mention are in fact different:

C:\Program Files\dir1\dir2\wizard\go.bat
C:\Program Files\dir1\dir2\wizard>go.bat
                                 ^
Roland Bouman
  • 31,125
  • 6
  • 66
  • 67
  • 1
    The second thing was from a command prompt window, apparently, according to the question, so the working directory was `C:\Program Files\dir1\dir2\wizard` and they were executing `go.bat` from there. – icktoofay Jun 07 '10 at 08:14
  • 1
    no they are the same C:\Program Files\dir1\dir2\wizard>go.bat go.bat is under wizard directory – yael Jun 07 '10 at 08:15