You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用IExpress将BAT转为EXE后,程序无法定位本地文件及接收拖放的问题解决请求

IExpress将BAT转为EXE后,程序无法定位本地文件及接收拖放的问题解决请求

大家好,我最近用IExpress把自己写的Test.bat转换成了Test.exe,但遇到了两个头疼的问题:

  • 生成的EXE没法找到本地的输入文件360_2016.mp4,运行时CMD窗口显示它的工作路径是TEMP临时目录,根本不是脚本所在的本地文件夹;
  • Test.exe不能接收拖放操作,虽然双击它能正常启动,但没法像原BAT文件那样拖放文件上去直接处理。

我现在需要修改Test.bat脚本,让转成的EXE能正确定位到输入文件,有没有大佬能帮忙看看怎么调整?


相关脚本与测试输出

1. 原始Test.bat脚本

echo off setlocal EnableDelayedExpansion

echo AA echo %1 echo AAA echo %~dp1

set "FN=%~n1.mp4" echo: echo FN= %FN%

pause

2. Test.bat拖放文件运行的CMD输出

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 . . .

3. 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 . . .

4. 用于转换的bat_to_exe.bat(IExpress脚本)

;@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=

备注:内容来源于stack exchange,提问作者CANJMP

火山引擎 最新活动