Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Inno setup 在Inno安装程序中使用shell xcopy命令_Inno Setup - Fatal编程技术网

Inno setup 在Inno安装程序中使用shell xcopy命令

Inno setup 在Inno安装程序中使用shell xcopy命令,inno-setup,Inno Setup,我正在尝试将附加文件夹/文件从{app}目录复制到Inno安装程序中程序文件中的其他文件夹。我已经用xcopy编写了一些代码来执行shell命令,但是我无法让它工作。我已经尝试了所有我能想到的权限智慧(shellexecasoriginaluser,Flag=runasoriginaluser,PrivilegesRequired=admin)。如果我手工输入并在cmd中运行它,它工作得很好,那么人们会认为这一定是权限问题吗?有什么想法吗 代码: [文件] 来源:“..\Dialogs\*”;D

我正在尝试将附加文件夹/文件从
{app}
目录复制到Inno安装程序中
程序文件
中的其他文件夹。我已经用
xcopy
编写了一些代码来执行shell命令,但是我无法让它工作。我已经尝试了所有我能想到的权限智慧(
shellexecasoriginaluser
Flag
=
runasoriginaluser
PrivilegesRequired=admin
)。如果我手工输入并在
cmd
中运行它,它工作得很好,那么人们会认为这一定是权限问题吗?有什么想法吗

代码:

[文件]
来源:“..\Dialogs\*”;DestDir:“{app}\Dialogs”;标志:ignoreversion recursesubdirs 64位;安装后:WriteExtensionsToInstallFolder();
[守则]
过程WriteExtensionsToInstallFolder();
变量
StatisticsInstallationFolder:字符串;
p参数:字符串;
runline:string;
结果代码:整数;
开始
StatisticsInstallationFolder:=SelectStatisticsFolderPage.值[0];
p参数:='@echo off'+#13#10
运行行:='xcopy/E/I/Y'+ExpandConstant('{app}')+'\Dialogs\*'''+ExpandConstant(StatisticsInstallationFolder)+'\ext''
如果不是ShellExec(“”,运行行,pParameter,“”,SW_SHOW,EWAitUnFilterminated,ResultCode),则
开始
MsgBox('无法复制插件'+IntToStr(ResultCode),mbError,mb_Ok);
结束;
结束;
  • FileName
    参数只能是
    xcopy
    (或者更确切地说是
    xcopy.exe
  • 命令行的其余部分转到
    Params
    参数
  • echo off
    参数是无意义的
  • 对于
    xcopy
    使用是一种过度使用,请使用普通
Exec('xcopy.exe','/E/I…,…)

不过为了更好地控制错误,您最好使用本机Pascal脚本函数:


最后一种最简单也是最好的方法是,针对您的具体情况,只需使用
[Files]
部分条目,其中包含:

[文件]
来源:“..\Dialogs\*”;DestDir:“{app}\Dialogs”;标志:ignoreversion recursesubdirs 64位;
来源:“..\Dialogs\*”;DestDir:“{code:GetStatisticsInstallationFolder}”;标志:ignoreversion recursesubdirs 64位;
[守则]
函数GetStatisticsInstallationFolder(参数:String):String;
开始
结果:=SelectStatisticsFolderPage.值[0];
结束;

非常感谢!我为此辛苦了几个小时,不客气。虽然我已经意识到还有更好的方法来满足你的特殊需求。请参阅我的最新答案。