[英]I want to run a 3rd party .exe file from a .bat file without a visible command prompt
首先,我创建了VBScript以运行没有可见命令提示符的批处理文件。
以下是代码:
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run Chr(34) & ("D:\Intouch_Printer_SW\spool12\spltotext.bat") & Chr(34), 0
Set WshShell = Nothing
以下是我运行第三方.exe文件的批处理文件代码。
for %%f in (C:\WINDOWS\system32\spool\PRINTERS\*.SPL) do (
echo %%~nf
start "" D:\Intouch_Printer_SW\spool12\spool.exe "C:\WINDOWS\system32\spool\PRINTERS\%%~nf.SPL" "Intouch Printer"
)
每当我运行.vbs代码时,都会弹出一个控制台窗口,我想在没有可见命令提示符的情况下执行所有操作。
由于以下代码片段,我认为我得到了一个黑色的窗口:
start "" D:\Intouch_Printer_SW\spool12\spool.exe "C:\WINDOWS\system32\spool\PRINTERS\%%~nf.SPL" "Intouch Printer"
start
在新窗口中打开命令。 运行控制台应用程序不是必需的,因此您可以将其删除:
for %%f in (C:\WINDOWS\system32\spool\PRINTERS\*.SPL) do (
echo %%~nf
D:\Intouch_Printer_SW\spool12\spool.exe "C:\WINDOWS\system32\spool\PRINTERS\%%~nf.SPL" "Intouch Printer"
)
另外,我建议从VBScript(将Run
方法的第3个参数设置为True
)同步运行批处理脚本,以避免任何人修改VBScript产生的不良影响。
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """D:\Intouch_Printer_SW\spool12\spltotext.bat""", 0, True
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.