目前我的批处理文件如下所示:
myprogram.exe param1
程序启动但DOS窗口仍然打开.我怎么能关闭它?
使用start命令可以防止批处理文件等待程序.只需记住在"开始"之后在要运行的程序前放置一个空的双引号.例如,如果要从批处理命令运行Visual Studio 2012:
Start "" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
开始后注意双引号.
您可以使用exit关键字.以下是我的一个批处理文件中的示例:
start myProgram.exe param1 exit
查看START命令,您可以这样做:
START rest-of-your-program-name
例如,此批处理文件将一直等到记事本退出:
@echo off notepad c:\test.txt
但是,这不会:
@echo off start notepad c:\test.txt
从我自己的问题:
start /b myProgram.exe params...
如果从现有DOS会话启动程序,则有效.
如果没有,请调用vb脚本
wscript.exe invis.vbs myProgram.exe %*
在Windows脚本宿主Run()方法需要:
intWindowStyle:0表示"隐形窗口"
bWaitOnReturn:false表示您的第一个脚本不需要等待第二个脚本完成
这是invis.vbs:
set args = WScript.Arguments
num = args.Count
if num = 0 then
WScript.Echo "Usage: [CScript | WScript] invis.vbs aScript.bat "
WScript.Quit 1
end if
sargs = ""
if num > 1 then
sargs = " "
for k = 1 to num - 1
anArg = args.Item(k)
sargs = sargs & anArg & " "
next
end if
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False
当我尝试从批处理文件中运行java类时,这是唯一有用的东西:
start "cmdWindowTitle" /B "javaw" -cp . testprojectpak.MainForm
您可以start
按照正确的语法自定义项目所需的命令:
Syntax START "title" [/Dpath] [options] "command" [parameters] Key: title : Text for the CMD window title bar (required) path : Starting directory command : The command, batch file or executable program to run parameters : The parameters passed to the command Options: /MIN : Minimized /MAX : Maximized /WAIT : Start application and wait for it to terminate /LOW : Use IDLE priority class /NORMAL : Use NORMAL priority class /HIGH : Use HIGH priority class /REALTIME : Use REALTIME priority class /B : Start application without creating a new window. In this case ^C will be ignored - leaving ^Break as the only way to interrupt the application /I : Ignore any changes to the current environment. Options for 16-bit WINDOWS programs only /SEPARATE Start in separate memory space (more robust) /SHARED Start in shared memory space (default)
你应该试试这个.它启动程序没有窗口.它实际上闪烁了一秒钟,但相当快地消失了.
start "name" /B myprogram.exe param1
如何解决"空间问题"和本地依赖关系:
@echo off cd "C:\Program Files\HeidiSQL" start heidisql.exe cd "C:\Program Files (x86)\Google\Chrome\Application" start chrome.exe exit