China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 02:25
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Proceed to ask about the specific path issue with WshShell.Run? Please provide more details about the path problem you are encountering, such as what exactly is not working or what specific path-related situation you are facing. View 2,267 Replies 10
Original Poster Posted 2007-04-01 14:40 ·  中国 广东 深圳 电信
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run("C:\Program Files\WinRAR\WinRAR.exe")
Says the specified file cannot be found???
This file exists!
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad "
Calling the program in the system directory has no error prompt!!!
Floor 2 Posted 2007-04-01 14:57 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
1. Do not use parentheses
2. VBS does not use variables like %windir% (unless generating VBS in batch processing). As long as it is a file stored in the system default variable directory (viewed with set in CMD), just write the file name directly.
Floor 3 Posted 2007-04-01 22:36 ·  中国 广东 深圳 电信
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
WshShell.Run("C:\Program Files\WinRAR\WinRAR.exe")
VBS: For function calls, it doesn't matter whether there are parentheses or not. Don't use parentheses for the sake of being standard. It's convenient to sometimes turn into JS. These two Windows scripting languages are basically similar. However, to develop a good writing style, it is still recommended to add parentheses when calling functions. This is also required by the standards of many languages like Java.
Also, this problem has been solved. The main reason is that the path has spaces and causes problems. You can use WshShell.Exec, but this function is mainly for 32-bit programs. Of course, it can also be solved like this: WshShell.Run("C:\Progra~1\WinRAR\WinRAR.exe"). This function is very strange, it seems to return to the DOS state and has space problems. VBS was also studied yesterday. If there are any mistakes, please correct them by everyone. In fact, JS and VBS are basically the same, and they can both achieve the same functions. However, since JS has problems with local permission calls, it is the same to expand it to *.hta! I forgot its interpreter name early in the morning :) But many antivirus tools are very easy to misdetect such files :( Note that such JS is JScript, which is exclusive to the Microsoft system, just like VBscript, not JavaScript
Floor 4 Posted 2007-04-01 22:43 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run createobject("scripting.filesystemobject").getfile("C:\Program Files\WinRAR\WinRAR.exe").ShortName
Floor 5 Posted 2007-04-02 00:59 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Just add quotes to him, no need to use short filenames.
set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run("""C:\Program Files\WinRAR\WinRAR.exe""")
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
jmz573515 +4 2007-04-02 01:10
Floor 6 Posted 2007-04-02 01:11 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Learning
Floor 7 Posted 2007-04-02 02:02 ·  中国 贵州 贵阳 电信
中级用户
★★
Credits 304
Posts 117
Joined 2006-04-04 18:43
20-year member
UID 53325
Gender Male
Status Offline
The method on floor 5 is really wonderful!!
Floor 8 Posted 2007-04-02 02:27 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
WshShell.Run is equivalent to you pasting the following string into the Run dialog box in the Windows Start menu.

So variables like %windir% can be supported.

Therefore, the problem of paths with spaces exists. So adding quotes to the called string can solve it.
Floor 9 Posted 2007-04-09 09:17 ·  中国 广东 深圳 宝安区 电信
中级用户
★★
Credits 379
Posts 95
Joined 2003-07-17 00:00
23-year member
UID 7038
Gender Male
Status Offline
C:\Program Files\UltraISO\UltraISO.exe G:\viursINx\ISO\3SwordPE.iso
How is such a problem determined?
Floor 10 Posted 2010-05-16 21:54 ·  中国 北京 联通
初级用户
Credits 31
Posts 17
Joined 2007-10-31 22:38
18-year member
UID 101331
Gender Male
Status Offline
Proceeding with the previous problem, here's the continuation:

——————————————
Two examples are given:
"D:\Program Files\Mozilla Firefox\firefox.exe" -safe-mode
"D:\Program Files\360\360safe\SoftMgr\SoftManager.exe" /page=3 /start=menuunist

After splitting by spaces, the program parameters are still used as they are.

***************************So, it should be:
set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run("""C:\Program Files\UltraISO\UltraISO.exe""" G:\viursINx\ISO\3SwordPE.iso)
Floor 11 Posted 2010-05-16 22:06 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Originally posted by ywjco at 2010-5-16 21:54:
An old question, continued now:
——————————————
Give two examples:
"D:\Program Files\Mozilla Firefox\firefox.exe" -safe-mode
"D:\Program Files\360\3 ...


You are wrong like this.
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore
Forum Jump: