2017-01-24 24 views
0

首先,我创建了VBScript来运行批处理文件,但没有可见的命令提示符。我想从.bat文件运行第三方.exe文件,但没有可见的命令提示符

以下是代码:

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" 
+0

您是否尝试过拨打电话而不是开始?除此之外,您可以使用'start/Min'命令行窗口最小化。 – geisterfurz007

+0

谢谢你!非常感谢。有效。 –

+2

这两者中的哪一个?我想添加一个答案:) – geisterfurz007

回答

1

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中运行批处理脚本(第3个参数Run方法设置为True),以避免任何人修改VBScript时出现不希望的副作用。

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run """D:\Intouch_Printer_SW\spool12\spltotext.bat""", 0, True 
相关问题