将 Test.bat 转换为 Test.exe 后,Test.exe 找不到本地输入文件 360_2016.mp4,EXE 文件 CMD 提示显示其路径是 TEMP 而不是本地目录/文件夹。EXE 文件不接受拖放,但对双击有响应。
需要修改 Test.bat,以便 Test.exe 能够找到输入文件。
BAT 到 EXE 的转换是使用‘iexpress’进行的。
以下是Test.bat脚本:
echo off setlocal EnableDelayedExpansion
echo AA echo %1 echo AAA echo %~dp1
set "FN=%~n1.mp4" echo: echo FN= %FN%
pause
通过拖放 Test.bat,以下是在 CMD 提示符下执行 Test.bat 的结果:
C:\Users\canjm\Desktop\STUFF\Test Area 9>echo off AA
"C:\Users\canjm\Desktop\STUFF\Test Area 9\360_2016.mp4" AAA
C:\Users\canjm\Desktop\STUFF\Test Area 9\
FN= 360_2016.mp4 Press any key to continue . . .
双击 Test.exe 后,在 CMD 提示符下得到的结果如下:
C:\Users\canjm\AppData\Local\Temp\IXP000.TMP>echo off
AA
ECHO is off.
AAA
ECHO is off.
FN= .mp4
Press any key to continue . . .
这是“iexpress”或bat_to_exe.bat脚本:
;@echo off
;Title Converting batch scripts to file.exe with iexpress
;Mode 75,3 & color 0A
;Rem Original Script https://github.com/npocmaka/batch.scripts/edit/master/hybrids/iexpress/bat2exeIEXP.bat
;echo(
;if "%~1" equ "" (
;echo Usage : Drag and Drop your batch file over this script:"%~nx0"
;Timeout /T 5 /nobreak>nul & Exit
;)
;set "target.exe=%__cd__%%~n1.exe"
;set "batch_file=%~f1"
;set "bat_name=%~nx1"
;set "bat_dir=%~dp1"
;Set "sed=%temp%\2exe.sed"
;echo Please wait a while ... Creating "%~n1.exe" ...
;copy /y "%~f0" "%sed%" >nul
;(
;(echo()
;(echo(AppLaunched=cmd /c "%bat_name%")
;(echo(TargetName=%target.exe%)
;(echo(FILE0="%bat_name%")
;(echo([SourceFiles])
;(echo(SourceFiles0=%bat_dir%)
;(echo([SourceFiles0])
;(echo(%%FILE0%%=)
;)>>"%sed%"
;iexpress /n /q /m %sed%
;del /q /f "%sed%"
;exit /b 0
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=1
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
FriendlyName=-
PostInstallCmd=<None>
AdminQuietInstCmd=