Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch that is being run with administrative privileges on a Windows 7 machine. That batch has to run another batch, which should access a mapped network drive. However, network drives are only mapped for the non-administrator part of the logged-in user. Since the second batch doesn't need the administrative rights, I'd like it to run as a limited user, and that will let it access the mapped drives. Is there any way to do that?

To make what I want clear, I'd like to get the following flow:

  1. User eran logs into PC. eran is a local administrator.
  2. eran runs b1.bat as administrator.
  3. b1.bat runs b2.bat with eran's limited user credentials (how? that's what I'm asking...)
  4. b2.bat accesses some mapped drives is now has access to.

Just in case the reason for the problem is not clear...

share|improve this question
Could you use drive mapping in the b2.bat file? net map z: \\server\share. Then follow up with net use z: /d? – Nixphoe Jul 10 '11 at 16:20
@Nixphoe - well, that's an interesting suggestion... not exactly what I was hoping for, but if there's no other way, I might go for it. Could you please write it as an answer? – eran Jul 10 '11 at 16:53
I updated my answer with that suggestion. – Nixphoe Jul 11 '11 at 1:25

You can use the runas command. Check out runas /? or Microsoft runas for more info. Put this in your b1.bat file.

runas /noprofile /user:username@domain.local "C:\batch\b2.bat"

Credit here

If that doesn't work you could map the drive in the b2.bat file. Add net map z: \\server\share. Then follow up with net use z: /d

share|improve this answer
Thanks, but this doesn't work :(... I'm using the same user to run both batches, and the admin credentials seem to propagate from the first to the second (I can't use some arbitrary local user, because then I won't have the network drives mapped). – eran Jul 10 '11 at 14:31

Create a scheduled task as user2. User1 executes that scheduled task which is configured to run in the context of user2. schtasks is the interface to run from the command line.

"schtasks /Run /TN taskname" would run the batch file for the other user.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.