简体   繁体   English

从批处理文件启动.exe时,奇怪的命令提示符挂起

[英]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.

相关问题 从批处理文件启动的命令提示符在操作停止时关闭 - Command prompt started from batch file closes when operation is stopped 启动批处理文件中隐藏的exe - Starting an exe hidden from a batch file 运行从 haskell 项目构建的 exe 文件时停止打开命令提示符 - Stop command prompt from opening when running exe file built from haskell project 为什么我不能从命令提示符运行这个 exe 文件? - why can't I run this exe file from the command prompt? 如何从管理命令提示符启动我的exe文件 - How to initiate my exe file from administrative command prompt 批处理文件:检测第二个命令提示符何时关闭? - batch file: detect when 2nd command prompt closes? 从Windows命令提示符/批处理文件中的路径字符串获取叶 - Getting the leaf from a path string in Windows Command Prompt/batch file 在命令提示符窗口中显示被调用批处理文件的输出? - showing output from a called batch file on command prompt window? 是否可以从批处理文件(命令提示符)中使用uglifyjs? 如果是这样,怎么办? - Is it possible to use uglifyjs from a batch file (command prompt)? If so, how? 编写批处理文件与在提示符下编写命令有何不同? - writing batch file is different from writing command in the prompt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM