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
1

2 Answers 2

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)
Sign up to request clarification or add additional context in comments.

Comments

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
                                 ^

2 Comments

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.
no they are the same C:\Program Files\dir1\dir2\wizard>go.bat go.bat is under wizard directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.