首先,我创建了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"发布于 2017-01-24 17:31:33
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方法的第三个参数设置为True),以避免任何人修改VBScript时产生的副作用。
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """D:\Intouch_Printer_SW\spool12\spltotext.bat""", 0, Truehttps://stackoverflow.com/questions/41821275
复制相似问题