![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-04 01:16 |
48,038 topics / 350,123 posts / today 0 new / 48,251 members |
| 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. |
| Printable Version 2,265 / 10 |
| Floor1 peterdocter | Posted 2007-04-01 14:40 |
| 中级用户 Posts 95 Credits 379 | |
|
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!!! |
|
| Floor2 zh159 | Posted 2007-04-01 14:57 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
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. |
|
| Floor3 peterdocter | Posted 2007-04-01 22:36 |
| 中级用户 Posts 95 Credits 379 | |
|
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 |
|
| Floor4 jmz573515 | Posted 2007-04-01 22:43 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run createobject("scripting.filesystemobject").getfile("C:\Program Files\WinRAR\WinRAR.exe").ShortName |
|
| Floor5 slore | Posted 2007-04-02 00:59 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
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""") |
|
| Floor6 jmz573515 | Posted 2007-04-02 01:11 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
Learning
|
|
| Floor7 wydos | Posted 2007-04-02 02:02 |
| 中级用户 Posts 117 Credits 304 | |
|
The method on floor 5 is really wonderful!!
|
|
| Floor8 slore | Posted 2007-04-02 02:27 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
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. |
|
| Floor9 peterdocter | Posted 2007-04-09 09:17 |
| 中级用户 Posts 95 Credits 379 | |
|
C:\Program Files\UltraISO\UltraISO.exe G:\viursINx\ISO\3SwordPE.iso
How is such a problem determined? |
|
| Floor10 ywjco | Posted 2010-05-16 21:54 |
| 初级用户 Posts 17 Credits 31 | |
|
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) |
|
| Floor11 slore | Posted 2010-05-16 22:06 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
Originally posted by ywjco at 2010-5-16 21:54: You are wrong like this. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |