Home > front end >  Consult a WIN10 VBS below call BAT is not successful
Consult a WIN10 VBS below call BAT is not successful

Time:11-02

In a product with the VBS to invoke the operation of the bat, I will simplify it as follows:

Postbuild_img2. VBS script (parameters for the three paths) calls a bat script, and the parameter passed to bat, as a means of debugging, bat has pause and echo, the VBS msgbox, can seem to have been run before, do not know how suddenly there is something wrong with recently, characterized by directly run the VBS, VBS msgbox all pop up, but didn't see bat run (no pause in the bat and the echo), if directly on the command line run the bat is no problem, doubt is computer environment, please help to look at,

Operating instructions are as follows:
C: \ Users \ A> Postbuild_img2. VBS C: C: \ \ Debug (only pop-up box, do not run the bat)
C: \ Users \ A> Postbuild_img2. Bat C: C: \ \ Debug (normal operation of the bat)

Two script code below
file 1:
Postbuild_img2. VBS:

Dim WshShell

The Set WshShell=WScript. CreateObject (" WScript. Shell ")
MsgBox (" [Ryan] ")
MsgBox (WScript. The Arguments. The Item (0))
MsgBox (WScript. The Arguments. The Item (1))
MsgBox (WScript. The Arguments. The Item (2))
MsgBox (" [start] ")
WshShell. Run CMD/c "c: \ Users \ 212781028 \ Ryan \ postbuild_img2 bat" + WScript. The Arguments. The Item (0) + "" + WScript. The Arguments. The Item (1) +" "+ WScript. The Arguments. The Item (2), and 0

MsgBox (" [over] ")

file 2
Postbuild_img2. Bat:


CD/D % 2
The set tooldir=% 2... Omit
The set libdir=% 2,... Omit
The set cfgdir=% 3

Echo config % 3
. Omit the subsequent code

CodePudding user response:

C: \ Debug
Parameters in whether have Spaces, special characters, "" quotes

CodePudding user response:

reference 1st floor horizon_zpy response:
C: \ Debug
Parameters in whether have Spaces, special characters, use "" quotes


Is, look down and there are two problems,
1: catalog has a space so I can't find the bat file, don't know is there a way to solve, now just modify the directory,
2: WshShell. Default is 0, behind the Run parameters to 1 every time running bat, 0 sometimes is not running, haven't found the reason,

CodePudding user response:

https://blog.csdn.net/xiao_cs/article/details/6262144

0 a hidden window and activates another window,
1 is activated window bat may need to activate the window

Is the path of the space can use "" around it
  • Related