How can I check if a folder exists if the user does not have read permissions?
I am writing a script to automate mapping of drives for users. The user has read permissions to their folder but not to the parent folder. So my current if statement
is going straight to else
even though the folder does exist.
My current code looks like this
if exist "\\domain\parent\%drive%" (
net use i: /delete
net use i: \\domain\parent\%drive% /P:YES
) else if exist "\\domain\parent\%username%" (
net use i: /delete
net use i: \\domain\parent\%username% /P:YES
) else (
echo error: folder not found
echo error: unable to map I drive
pause
exit
)
So the user has read permissions to their folder name, structured either %drive%
or %username%
, but they do not have read permissions to the parent
folder.
I am able to map the drive manually but I'm wondering if it's possible to use if exist
to check if folders exist even if the user does not have read permissions to the parent
?
UPDATE: This code works if the user has read permissions to the parent and sub folders but is there some way to check if the file exists even if the user does not have read permissions to the parent folder?