我使用Inno Setup创建了一个安装程序,其中包含5个文件.我添加了一个附加功能,以便用户可以将其安装在自定义路径中.
安装后,将在选定路径中创建一个文件夹.现在我将复制此文件夹中的其他一些文件.但在卸载后,会发生以下情况:
让用户在默认位置安装它,然后一个新文件夹说在该位置创建了myfolder,现在用户创建了2个新文件并将它们复制到该文件夹中.卸载后没有问题; myfolder将与2个新文件(安装后创建)一起删除.
现在让用户将其安装在自定义位置,然后新文件夹说在该位置创建了myfolder,现在用户创建了2个新文件并将其复制到该文件夹中.卸载后,myfolder没有删除,因为其中有2个新文件(安装后创建).
这是我的代码:
function GetInstalledLocation(): String;
var
installLocation: String;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ {36CBFC-6ACC-4232-90CF-E95BC473C168}_is1') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1536CBFC-6ACC-4232-90CF-E95BC473C168}_is1', 'InstallLocation', installLocation);
Result := installLocation
end;
end;
function InitializeUninstall(): Boolean;
var
InstalledLocation : String;
begin
Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnUninstallMessage, True );
// Unload the DLL, otherwise the dll psvince is not deleted
UnloadDLL(ExpandConstant('{app}\psvince.dll'));
if not Result then
begin
MsgBox( UninstallationCanceledMessage, mbInformation, MB_OK );
end
else
begin
InstalledLocation := GetInstalledLocation();
;DelTree('{InstalledLocation\*}', True, True, True);
DelTree('{InstalledLocation}', True, True, True);
; DelTree('ExpandConstant({InstalledLocation\*})', True, …Run Code Online (Sandbox Code Playgroud) 是否有批处理命令来搜索和替换环境变量PATH中的字符串?
例如,环境变量PATH的内容是:
C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AccuRev\bin;C:\Python24
Run Code Online (Sandbox Code Playgroud)
我必须C:\Python24在这个变量中搜索并需要替换它C:\Python27.