windows 隐藏简单的批处理窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6941167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hiding a simple batch window
提问by Amir Zadeh
I've searched this and some pages came which weren't really useful or were too complicated (I am not a skilled batch file programmer!)! What I need is to run a batch file in hidden form (no console window). The batch file will not be called from external application or code. It will be clicked on by the client and then I want no console pages to be shown (only pages which are called by call command should be shown)! The batch file is exactly as follows:
我已经搜索过这个,有些页面并不是真正有用或太复杂(我不是一个熟练的批处理文件程序员!)!我需要的是以隐藏形式(无控制台窗口)运行批处理文件。不会从外部应用程序或代码调用批处理文件。它将被客户端单击,然后我不希望显示任何控制台页面(仅应显示由 call 命令调用的页面)!批处理文件如下:
@echo off
call setup.exe
IF EXIST "C:/caillog" goto tracking
IF NOT EXIST "C:/caillog" goto end
:tracking
call dotnet4.exe
call ClientService.msi
goto end
:end
回答by Bali C
I use VBScripts to open it hidden, like this:
我使用 VBScripts 打开它隐藏,像这样:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("%batchfile%"), 0, True
for e.g the bat file I want to run is run.bat
then I'll do like this
例如,我想运行的 bat 文件是run.bat
然后我会这样做
objShell.Run("run.bat"), 0, True
Instead of running the batch file run the vb file.
运行 vb 文件而不是运行批处理文件。
Write it in notepad and save it as *.vbs
写在记事本中并保存为*.vbs
回答by Amir Zadeh
As others have said, use VBS.
正如其他人所说,使用 VBS。
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\FilePath" & Chr(34), 0
Set WinScriptHost = Nothing
This is what I use.
这就是我使用的。