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: Install a File as a Different Name - Replacing an Existing File
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
‎Sep 11, 2008
08:06 AM
Install a File as a Different Name - Replacing an Existing File
In an InstallScript project, I need to install a renamed file. The file may already exist. Unfortunately, if the file has the read-only bit on, it cannot be deleted with DeleteFile, so a combination of DeleteFile and RenameFile does not seem to work. Example: In the build, the file is named "A", in the destination machine, it is named "B", and has the read-only bit on. (The file name is the same as the instance name in our architecture.)
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 11, 2008
09:40 AM
The solution was fairly simple - change the read-only flag before deleting. Here is a working version of a function that accomplishes this:
function RenameFileOver(szDir, szFromFile, szToFile)
string szFileFound;
beginif (FindFile (szDir, szToFile, szFileFound) = 0) then
RenameFile (szDir ^ szFromFile, szDir ^ szToFile);
end;SetFileInfo (szDir ^ szToFile, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, "");
DeleteFile(szDir ^ szToFile);
endif;DeleteFile(szDir ^ szToFile);
RenameFile (szDir ^ szFromFile, szDir ^ szToFile);
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 15, 2008
03:50 PM
For some reason, a file on one machine leads to a return code of "Access is Denied", by DeleteFile, even after the SetFileInfo method is called. Unfortunately, I am now stuck. When I run the InstallShield-built install, it gives this error, yet I have sufficient privileges on this Windows 2000 machine to delete the file. Any ideas?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 16, 2008
06:18 PM
Maybe the file is locked. Did you check if it is possible to delete it manually in Explorer?
XCopyFile with the LOCKEDFILE paramtere can handle locked files. It replaces them after a reboot. But I think it can't combine a rename operation with the copy. You would have to do that separately before the xcopy.
-Sandra
XCopyFile with the LOCKEDFILE paramtere can handle locked files. It replaces them after a reboot. But I think it can't combine a rename operation with the copy. You would have to do that separately before the xcopy.
-Sandra
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)