[英]Weird Command Prompt hang when starting .exe from a batch file
I like to portable-ise as many programs / apps as I can, so I regularly create self-executing SFX archives that extract to %temp%
and then run a selected file (usually the original .exe or, if necessary, a .bat file). 我喜欢尽可能多地移植程序/应用程序,所以我会定期创建自执行的SFX存档,将其提取到
%temp%
,然后运行选定的文件(通常是原始.exe或(如果需要).bat)文件)。
I'm trying to combine a x86 and x64 version of an app into one version, as I don't like having 2 files. 我正在尝试将应用程序的x86和x64版本合并为一个版本,因为我不希望拥有2个文件。 So, I have 2 folders ("x86" and "x64") containing the different versions of the program and a .bat file in the root that will check the user's bitness and then launch the appropriate version.
因此,我有2个文件夹(“ x86”和“ x64”)包含该程序的不同版本,并且在根目录中有一个.bat文件,该文件将检查用户的位数,然后启动相应的版本。 I'm having a few issues, though.
不过,我遇到了一些问题。
Here is my code: 这是我的代码:
checkandrun.bat 检查并运行
@echo off
goto Payload
:Payload
echo Checking architecture bit-type...
IF EXIST "%systemRoot%\SysWOW64" (
echo Your version of Windows is 64-bit [x64]
start "x64\GCFScape.exe" >nul
) ELSE (
echo Your version of Windows is 32-bit [x86]
start "x86\GCFScape.exe" >nul
)
echo.
echo Starting the appropriate version...
goto End
:End
echo.
echo This window will close in 20 seconds.
ping localhost -n 21 >nul
exit
If I use start
then the original command window will exit correctly, as desired, but will open up a new, constant command window and the app won't launch. 如果我使用
start
则原始命令窗口将根据需要正确退出,但会打开一个新的恒定命令窗口,而该应用程序将无法启动。
If I don't use start
the app will launch but the command window will stay open and won't progress past the line of code that was used to launch the .exe. 如果我不使用
start
则应用程序将启动,但命令窗口将保持打开状态,并且不会越过用于启动.exe的代码行。 If I close the app itself then the command window will proceed as normal to the exit
command and close successfully. 如果我关闭应用程序本身,则命令窗口将正常执行
exit
命令并成功关闭。
Is there is a way around this? 有办法解决吗? I've never had this kind of problem before.
我以前从未遇到过此类问题。
Here is a link to the SFX archive in my Dropbox, if anyone wants to take an actual look at the environment and effects for themselves: https://dl.dropbox.com/u/27573003/Social%20Distribution/gcfscape182.exe 如果有人想亲自了解一下环境和效果,这是我Dropbox中SFX存档的链接: https : //dl.dropbox.com/u/27573003/Social%20Distribution/gcfscape182.exe
The docs for the START command say that the first arg that is in quote marks will be the title of the window. START命令的文档说,带引号的第一个arg将是窗口的标题。 So, try this:
因此,请尝试以下操作:
start /B "GCFScape" "x64\GCFScape.exe">nul
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.