NET USE remove if no right

0

1

I have a .bat for connecting network drives. I have 11 in total. My script works, but for now even if the user has no rights, that it connect the network drive.

I would like if the user does not have the rights, the network drive is removed.

Do you know something like that ?

inksis

Posted 2015-04-30T15:56:49.967

Reputation: 1

Answers

0

You could try checking the errorlevel after the "dir X:\" command. The errorlevel is the integer value returned of the last executed command in your command line session. 0 means success

if errorlevel 1 command

means command is executed if the errorlevel is greater or equal 1

:drivex
net use x: \\computer\share
if errorlevel 1 goto drivey
dir x:\
if errorlevel 1 goto drivexremove
goto drivey
:drivexremove
net use x: /delete
:drivey
net use ....

mnfc12

Posted 2015-04-30T15:56:49.967

Reputation: 66