This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Simple (surely) InstallScript (no MSI) question on DeleteFile()
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 10, 2009
07:26 PM
Simple (surely) InstallScript (no MSI) question on DeleteFile()
This seems to me a really simple one, but not when I really work on it:(
I try to delete an .ini file from WINDIR at the end of uninstall, it was installed (and modified after installation) by the installer (InstallScript no MSI), but I just can't make it work. Following is the code:
The code is executed, and DeleteFile() returns non-negative value (the SEVERE msg is not displayed), but the file is still there when I navigate to WINDIR.
Any suggestions?
Thanks,
Peter
I try to delete an .ini file from WINDIR at the end of uninstall, it was installed (and modified after installation) by the installer (InstallScript no MSI), but I just can't make it work. Following is the code:
...
TARGETDIR = WINDIR;
sIni = TARGETDIR^"MyFile.ini";
SetFileInfo (sIni, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
if(DeleteFile(sIni) < 0) then
MessageBox ("DeleteFile failed.", SEVERE);
endif;
...
The code is executed, and DeleteFile() returns non-negative value (the SEVERE msg is not displayed), but the file is still there when I navigate to WINDIR.
Any suggestions?
Thanks,
Peter
(9) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
12:54 AM
use WindowsFolder in place of WINDIR and then try.....
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
08:28 AM
DeleteDir can also return a couple of positive values; perhaps display the specific value? In what event are you calling that code?
(It's probably not necessary to set TARGETDIR to WINDIR, though that doesn't seem it would have a bearing on the issue.)
(It's probably not necessary to set TARGETDIR to WINDIR, though that doesn't seem it would have a bearing on the issue.)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
01:03 PM
Hi Robert and Chandan,
Thanks you both for your attention to my posts.
First of all, 'WindowsFolder' is not a valid property for InstallScript project (IS2009 help specified "Thsi information does not apply to InstallScript projects".).
Robert is right that it's not necessary to set TARGETDIR here, I directly used WINDIR and got the same result - so he is also right that it is not the problem here.
I changed the code to the following
The code is still executed fine - the failed message is NOT displayed. Any other more robust workaround for DeleteFile() in InstallScript?
I desparately need help now:confused:
Thanks,
Peter
Thanks you both for your attention to my posts.
First of all, 'WindowsFolder' is not a valid property for InstallScript project (IS2009 help specified "Thsi information does not apply to InstallScript projects".).
Robert is right that it's not necessary to set TARGETDIR here, I directly used WINDIR and got the same result - so he is also right that it is not the problem here.
I changed the code to the following
...
sIni = WINDIR^"MyFile.ini";
SetFileInfo (sIni, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
if(DeleteFile(sIni) != 0) then
MessageBox ("DeleteFile failed.", SEVERE);
...
The code is still executed fine - the failed message is NOT displayed. Any other more robust workaround for DeleteFile() in InstallScript?
I desparately need help now:confused:
Thanks,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
01:05 PM
Please note the following change:
if(DeleteFile(sIni) != 0) then
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
01:10 PM
Hi Robert and Chandan,
Thanks you both for your attention to my posts.
First of all, 'WindowsFolder' is not a valid property for InstallScript project (IS2009 help specified "Thsi information does not apply to InstallScript projects".).
Robert is right that it's not necessary to set TARGETDIR here, I directly used WINDIR and got the same result - so he is also right that it is not the problem here.
I changed the code to the following
The code is still executed fine - the failed message is NOT displayed. Any other more robust workaround for DeleteFile() in InstallScript?
I desparately need help now:confused:
Thanks,
Peter
Thanks you both for your attention to my posts.
First of all, 'WindowsFolder' is not a valid property for InstallScript project (IS2009 help specified "Thsi information does not apply to InstallScript projects".).
Robert is right that it's not necessary to set TARGETDIR here, I directly used WINDIR and got the same result - so he is also right that it is not the problem here.
I changed the code to the following
...
sIni = WINDIR^"MyFile.ini";
SetFileInfo (sIni, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
if(DeleteFile(sIni) != 0) then
MessageBox ("DeleteFile failed.", SEVERE);
...
The code is still executed fine - the failed message is NOT displayed. Any other more robust workaround for DeleteFile() in InstallScript?
I desparately need help now:confused:
Thanks,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
01:12 PM
One more thing I forgot (for Robert).
The function was plugged in as OnUninstalled event of the main feature of the product (Setup Design->main_feature->OnUninstalled).
Thanks,
Peter
The function was plugged in as OnUninstalled event of the main feature of the product (Setup Design->main_feature->OnUninstalled).
Thanks,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
01:59 PM
Some updates:
I tried to delete the file during the execution of the code block (added a messagebox before calling DeleteFile()), I could delete it, but after uninstall I found the file was created!
So I think the problem is not DeleteFile() itself, but the sequence (or position at uninstall) to call the function. Obviously some action(s) re-created the .ini file after OnUninstalled event of the main feature. I als tried other features, non of them is late enough to be after the re-creation.
The code is relatively (yes just relatively) simple, I am pasting the main functions in setup.rul below
At uninstall, 'OnShowUI()' is not executed, and I can't see any other custom code to deal with uninstall, so it seems to me the whole uninstall process is controled by ...\setup.exe -uninst ....
Then which event controller (function call) is late enough that I can use to do the file deletion?
Thanks,
Peter
I tried to delete the file during the execution of the code block (added a messagebox before calling DeleteFile()), I could delete it, but after uninstall I found the file was created!
So I think the problem is not DeleteFile() itself, but the sequence (or position at uninstall) to call the function. Obviously some action(s) re-created the .ini file after OnUninstalled event of the main feature. I als tried other features, non of them is late enough to be after the re-creation.
The code is relatively (yes just relatively) simple, I am pasting the main functions in setup.rul below
function OnShowUI()
...
begin
if _IsRestartAndFinish() then
_InitVariablesAfterRestart();
_InitScreen();
_RunUpdatePgm();
...
_RemoveRegistryEntry();
_AllDone();
else
_InitVariables();
_BuildNetworkLists();
_InitScreen();
_DoGUIs();
...
_UpdateFiles();
_UpdateIniFiles();
_RunUpdatePgm();
_AlmostDone();
_AllDone();
endif;
end;
function _DoGUIs()
begin
while (nDoNext <= _DO_UPDATE_FILES)
switch( nDoNext )
case _DO_WELCOME:
_Welcome();
nDoNext = _DO_EULA ;
case _DO_EULA:
_EULA();
case _DO_NUMUSER:
...
case _DO_LOCK_MGR:
...
case _DO_GET_PATH:
...
case _DO_LOCK_FILES:
...
case _DO_UPDATE_FILES:
_DeleteOldFiles();
if ( gIsMultiuser) then
InstallFirstUser();
endif;
nDoNext = _DO_UPDATE_FILES +1;
default:
_Terminate();
endswitch;
endwhile;
end;
At uninstall, 'OnShowUI()' is not executed, and I can't see any other custom code to deal with uninstall, so it seems to me the whole uninstall process is controled by ...\setup.exe -uninst ....
Then which event controller (function call) is late enough that I can use to do the file deletion?
Thanks,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
02:05 PM
Is that possible to modify the ...\setup.exe -uninst ... to create a log file to what events/functions are executed during uninstall?
Thanks,
Peter
Thanks,
Peter
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 13, 2009
02:20 PM
All done!
Big lesson to learn for InstallScript projects:(
I got the OnUninstall() function by going to IDE->InstallScript->Advanced->OnUninstall(), and add my function call at the end of OnUninstall(), everything works!
Thanks to anyone who payed attention to my posts.
Regards,
Peter
Big lesson to learn for InstallScript projects:(
I got the OnUninstall() function by going to IDE->InstallScript->Advanced->OnUninstall(), and add my function call at the end of OnUninstall(), everything works!
Thanks to anyone who payed attention to my posts.
Regards,
Peter
