Link to home
Start Free TrialLog in
Avatar of ChiefIT
ChiefITFlag for United States of America

asked on

access denied for users to run Net Use within a batch file to initiate logon scripts.

I have some small scripts that delete all mapped drives and recreate the mapped drives using the Net Use command.
Net Use * \Delete /yes
Net Use \\computer\share /yes

These run fine for the administrator, but not the user

Also, the users each have another mapped network drive that is used for their home folder. This has been created using their active directory profile. I don't want to delete that folder.

Can anyone help me come up with a good way of doing this?

I stink at creating these batch files and scripts.
SOLUTION
Avatar of sharkbot221984
sharkbot221984
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Darius Ghassem
Darius Ghassem
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey Chief,

I like this way better(VBS)


'Disconnect ALL mapped drives
dim WshNetwork

Set WshNetwork = CreateObject("WScript.Network")
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Map the Drive
  WshNetwork.MapNetworkDrive "K:", "\\computer\share",True
Ps their home folder mapping will be recreated since you have defined it in AD profile.
Avatar of ChiefIT

ASKER

The net use command is the way I was doing things before. They all of a sudden quit working.

So, I went into Joe.Testuser account to watch the command window and found they were getting access denied. Then, I went to the command prompt and tried to manually run net use .... from there with access denied. I think it safe to assume, if you are not the domain or local admin net use is denied from running. That leads me to believe that net use is not the way to go any more.

I do like the above VB sript and would like a bit more info on what it does.. I have up to ten drives to map on some users.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ChiefIT

ASKER

For some folks the net use command might work. I am going to switch to VB scripts and start learning these. So, I really do appreciate the help on netuse that was offered above, but I found the help on the VB script more up my alley.

Well done dstwrtjr: