I wrote a batch file which creates a file on the C: drive root folder. However if logging in as a normal user, the file won't be created and I will get an "Access Denied" error.
How can I avoid this problem?
|
I wrote a batch file which creates a file on the C: drive root folder. However if logging in as a normal user, the file won't be created and I will get an "Access Denied" error. How can I avoid this problem? |
||||
|
|
|
The user does not have permission to write to the root of the drive. You need to create the file in a location that the user has write access to. For example, their Application Data folder. The root of the C drive is typically locked down to prevent you from writing into it, as it is not best practice to do so. If you absolutely must write into the root of the drive, edit the NTFS permissions for the drive to permit the user to write to it. But be aware that this is not a good way to go about things. |
|||
|
|
|
As stated, using %TEMP% or %TMP% is recommended if the file does not need to be kept tracked of/saved. If not, I would just use %USERPROFILE% (c:\Documents and Settings\normal) where 'normal' is your username... as that is the simplest/logical place to put it if you do not have the correct privileges to access the root directory. %USERPROFILE%\desktop if you want it to be placed on the desktop for easy access. |
|||
|
|
|
Instead of using a "hardcoded" path, you could use one that usually can be written to such as Alternatively, you can have the user to specify the absolute filename to use. If you really need admin rights, you can use the |
||||
|
|
|
I fully agree to what has been said here already. In addition I think Remember that also |
|||
|
|