Mis*_*Dev 178 windows batch-file
目前我的批处理文件如下所示:
myprogram.exe param1
Run Code Online (Sandbox Code Playgroud)
程序启动但DOS窗口仍然打开.我怎么能关闭它?
小智 244
使用start命令可以防止批处理文件等待程序.只需记住在"开始"之后在要运行的程序前放置一个空的双引号.例如,如果要从批处理命令运行Visual Studio 2012:
Start "" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
Run Code Online (Sandbox Code Playgroud)
开始后注意双引号.
Pat*_*ins 159
您可以使用exit关键字.以下是我的一个批处理文件中的示例:
start myProgram.exe param1
exit
Run Code Online (Sandbox Code Playgroud)
ang*_*son 52
查看START命令,您可以这样做:
START rest-of-your-program-name
Run Code Online (Sandbox Code Playgroud)
例如,此批处理文件将一直等到记事本退出:
@echo off
notepad c:\test.txt
Run Code Online (Sandbox Code Playgroud)
但是,这不会:
@echo off
start notepad c:\test.txt
Run Code Online (Sandbox Code Playgroud)
Von*_*onC 30
从我自己的问题:
start /b myProgram.exe params...
Run Code Online (Sandbox Code Playgroud)
如果从现有DOS会话启动程序,则有效.
如果没有,请调用vb脚本
wscript.exe invis.vbs myProgram.exe %*
Run Code Online (Sandbox Code Playgroud)
这是invis.vbs:
set args = WScript.Arguments
num = args.Count
if num = 0 then
WScript.Echo "Usage: [CScript | WScript] invis.vbs aScript.bat <some script arguments>"
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
Run Code Online (Sandbox Code Playgroud)
Zos*_*mas 19
当我尝试从批处理文件中运行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)
Run Code Online (Sandbox Code Playgroud)
Chr*_*ail 18
你应该试试这个.它启动程序没有窗口.它实际上闪烁了一秒钟,但相当快地消失了.
start "name" /B myprogram.exe param1
Run Code Online (Sandbox Code Playgroud)
Gil*_*lco 14
如何解决"空间问题"和本地依赖关系:
@echo off
cd "C:\Program Files\HeidiSQL"
start heidisql.exe
cd "C:\Program Files (x86)\Google\Chrome\Application"
start chrome.exe
exit
Run Code Online (Sandbox Code Playgroud)
这个问题已经有很多答案了,但是我发布这个是为了强调一些重要的事情:
Start "C:\Program Files\someprog.exe"
Run Code Online (Sandbox Code Playgroud)
上述内容可能会在某些 Windows 版本中导致问题,因为Start
实际上期望第一组引号是 Windows 标题。因此,最佳实践是首先双引号注释或空白注释:
Start "" "C:\Program Files\someprog.exe"
Run Code Online (Sandbox Code Playgroud)
或者
Start "Window Title" "C:\Program Files\someprog.exe"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
682056 次 |
最近记录: |