[英]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.