PDA

View Full Version : How do I check file in use and spot that it is a permissions issue



jgamalinda
05-20-2010, 12:09 PM
Before letting the install run I am checking to see if my .exe is running (anywhere on the network). The function - check in use file will return true if the user does not have permission. At an actual user site in windows explorer any action against my .exe was an error 5 Access Denied due to permissions, I know my .exe was not running there. I was not installing on the server.

Is there any way to spot the user running the setup.exe does not have permission to replace my .exe file (or any folder files) so I can provide a better error message for them?

E.g.
Set Variable %NoPerm% Check File Permissions "%_SB_INSTALLDIR%\myapp.exe"
IF %NoPerm% > 0 THEN
Display Message "You Do Not Have Permissions to Install. Login as admin"
Exit_Installation()
END

Set Variable %IsRunning% Check File InUse "%_SB_INSTALLDIR%\myapp.exe"
IF %IsRunning% > 0 THEN
Display Message "All Users must exit, someone is running myapp.exe"
Cycle Loop
END

Do you know of some good example code on how to figure out the cause of an error 5. I can think of 3 causes:
1. File is in use
2. File is marked Read Only
3. User does not have Permissions
D. The User Account that Owned the file has been deleted

linder
05-21-2010, 01:34 AM
Hello,

No, the Windows APIs do not give you the information that let you find out why a file is not writable. But you can use the "Get File Info..." script function to read the file attributes (e.g. "read-only").

Of course, if you have developed your own patent pending algorithm to handle permission/file in-use checking, you can develop a DLL and call that function from the installer. But please don't forget to send us the code so we can add it into SetupBuilder ;)

Friedrich