问题描述
因此,我编写了一个批处理文件,将客户端转换为云服务,并且看到了一些奇怪的行为.
So I wrote a batch file to convert clients over to a cloud service and I'm seeing some weird behavior from it.
因此,这基本上是在寻找一个特定的文件夹,无论它是否存在,它都会使用GOTO继续前进.当我使用WinRAR将其压缩到SFX中并指示它运行批处理文件时,它永远不会检测到该文件夹,但是,当我运行批处理文件本身时,它始终会检测该文件夹,无论是否存在该文件夹.我已经尝试了好几天了,但我只是不明白为什么会这样.
So this basically looks for a specific folder and whether or not it exists it uses GOTO to move on. When I compress this using WinRAR into a SFX and instruct it to run the batch file it NEVER detects the folder, however, when I run the batch file itself, it ALWAYS detects the folder, whether its there or not. I've been trying to figure this out for a few days now and I just don't understand why this is happening.
@ECHO Off
CD %~dp0
Goto DisableLocal
:DisableLocal
IF EXIST "%ProgramFiles%\Server\" (
GOTO Server
) ELSE (
GOTO Config
)
推荐答案
我也遇到了同样的问题,我正在尝试这种方式,但是不确定是否可以在Windows 32位系统上使用.
I have the same problem, I'm trying this way, but not sure if will work on a Windows 32 bits.
@ECHO Off
IF DEFINED ProgramW6432 (
SET "ServerPath=%ProgramW6432%\Server\"
) ELSE (
SET "ServerPath=%ProgramFiles%\Server\"
)
CD %~dp0
Goto DisableLocal
:DisableLocal
IF EXIST "%ServerPath%" (
GOTO Server
) ELSE (
GOTO Config
)
这篇关于从SFX运行时,批处理文件的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!