In vbs, if the program to be run contains spaces, errors are often prompted in the usual way. In fact, there are two different solutions:
- Add three double quotes before and after the application. The Code is as follows:
[C-sharp] View plaincopyprint?
- Set wshell = Createobject ("wscript. Shell ")
- Wshell. Run "" C:/program files/360/360 SE/360se.exe ", 5, true
- Set wshell = nothing
Set wshell = Createobject ("wscript. Shell") wshell. Run "" C:/program files/360/360 SE/360se.exe ", 5, true set wshell = nothing
- Use CHR (34) to enclose strings with quotation marks. The Code is as follows:
[C-sharp] View plaincopyprint?
- Temp = "C:/program files/360/360 se3/360se.exe"
- Path = CHR (34) & temp & CHR (34)
- Set wshell = Createobject ("wscript. Shell ")
- Wshell. Run path, 1, true
- Set wshell = nothing
Temp = "C:/program files/360/360 se3/360se.exe" Path = CHR (34) & temp & CHR (34) set wshell = Createobject ("wscript. shell ") wshell. run path, 1, true set wshell = nothing
3. To increase readability, use the following code to define constants:
[C-sharp] View plaincopyprint?
- Public const vbquote = """"
- Temp = "C:/program files/360/360 se3/360se.exe"
- Path = vbquote & temp & vbquote
- Set wshell = Createobject ("wscript. Shell ")
- Wshell. Run path, 1, true
- Set wshell = nothing
Public const vbquote = "temp =" C:/program files/360/360 se3/360se.exe "Path = vbquote & temp & vbquoteset wshell = Createobject (" wscript. shell ") wshell. run path, 1, true set wshell = nothing
Some explanations:
- Because vbs regards double quotation marks as a value container, if you need to use double quotation marks as a value, you need to use a double quotation mark before and after it.
- While CHR (integer I) is the character corresponding to I in the ASCII code table, and 34 corresponds to double quotation marks in the ASCII code table.