Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.



Windows 7: Run login command as Administrator

21 Feb 2010   #1

XP, Vista, W7, all flavors
 
 
Run login command as Administrator

I used to have a network drive mapped to U:, but I have moved it to the local machine.

Some programs (one in particular: iTunes) don't do well if you move their file paths around, plus it would be nice if all the machines on the network could have the same setup. So now I want to have a virtual u: mapped to a location on C:\.

I could use NET USE. However, 1) this means I now have to maintain share permissions as well as local permissions (although this is not a big deal) and 2) I am not sure if this is a waste of resources- is the system now routing all this traffic through the network layer when it doesn't have to?

So I want to use "subst". The problem on Vista/Windows 7 is that this is a per-user command, and it will not show up in the explorer unless it has been run twice- as both the current user and as Administrator.

So the question becomes: How do you run the command (either in a batch file or through some registry entry) as an Administrator at User login?

(Note: I am currently using NET USE with a localhost address. If someone has a better solution to this, please post. But it would also be nice to know how to run the admin command for any and all users at login).

My System SpecsSystem Spec
.

21 Feb 2010   #2

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

SUBST U: C:\

Add it to the RUN in the registry so it will run everytime someone logon's in.

Add the command to the RUN key in the registry under HKLM
My System SpecsSystem Spec
21 Feb 2010   #3

XP, Vista, W7, all flavors
 
 

Will that run it as the administrator? Everything that's running now from those keys is running under the logged in user.
My System SpecsSystem Spec
.


22 Feb 2010   #4

XP, Vista, W7, all flavors
 
 

Well, I looked all around the web and found only one way to do it. Set up a batch file and then use Task Scheduler to run it as the Admin at the USER logon. (You need to enable the Admin account and set a password first).

To accomplish my subst command, you also need to set up the same Task to run as the User (in my case, all users) at logon also.

Now, when I log in, I have the local drive mapped to a distinct drive letter, without going through the network layer! Hallelujah!
My System SpecsSystem Spec
22 Feb 2010   #5

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Quote   Quote: Originally Posted by ultralame View Post
Will that run it as the administrator? Everything that's running now from those keys is running under the logged in user.
It will run as ANY user, including Administrator.
My System SpecsSystem Spec
23 Feb 2010   #6

XP, Vista, W7, all flavors
 
 

Right- those keys will run at login for the user who is logging in. But I need the command to run both as the User and as Administrator. Those keys do not allow you to specify another user.

It is annoying. Also, my solution above does not seem to work consistently. The admin invocation does not always seem to run.
My System SpecsSystem Spec
23 Feb 2010   #7

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Quote   Quote: Originally Posted by ultralame View Post
Right- those keys will run at login for the user who is logging in. But I need the command to run both as the User and as Administrator. Those keys do not allow you to specify another user.

It is annoying. Also, my solution above does not seem to work consistently. The admin invocation does not always seem to run.
You can specify a user by using HKCU key. This will run only as that user. I Hope that helps. This way you can have a key for Administrator, User, David, Bill, Joe etc..
My System SpecsSystem Spec
24 Feb 2010   #8

XP, Vista, W7, all flavors
 
 

> You can specify a user by using HKCU key. This will run only as that user. I Hope that helps. This way you can have a key for Administrator, User, David, Bill, Joe etc..

Are you saying that you can set up a key so that when David logs in, the command will execute under both David and Administrator? HKCU will only run the command as the user that is logging in (David).
My System SpecsSystem Spec
24 Feb 2010   #9

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Quote   Quote: Originally Posted by ultralame View Post
> You can specify a user by using HKCU key. This will run only as that user. I Hope that helps. This way you can have a key for Administrator, User, David, Bill, Joe etc..

Are you saying that you can set up a key so that when David logs in, the command will execute under both David and Administrator? HKCU will only run the command as the user that is logging in (David).
Yes here is how:

Scenario:

You have 5 users on your machine.
You want User Administrator and User David to run the SUBST command.
You have Users Bill, Joe, and Mary and you DO NOT want them to run the SUBST command.

Add the SUBST U: C:\ command in HKCU for both Administrator and David.

Donít add the command to any of the other users.

When either Administrator or David logs on the machine the SUBST U: C:\ will run.

When anyone else logs on to the machine, since the command does not exist in their profile nothing will get substituted.

I hope that helps.
My System SpecsSystem Spec
25 Feb 2010   #10

XP, Vista, W7, all flavors
 
 

>When either Administrator or David logs on the machine the SUBST U: C:\ will run.

What I need is to have the command run by BOTH David AND Administrator WHEN David logs on. Whenever any user logs in, the command needs to be run both normally and as the administrator in their logon session.

Here's what I do now...

1) Logon
2) Open a cmd window, run the subst command. Close Cmd window.
3) Open a cmd window AS ADMINISTRATOR, run same subst command. Close Cmd window.
4) Check "My Computer". The subst drive is now visible.

The only way I have been able to accomplish this is to create a batch file and then create two identical tasks for it in Task Scheduler. Both tasks run at User logon. One task is set up to run as the User, the other is set up to run as the Administrator.

The problem now is that it does not seem to work every time, roughly 50/50.
My System SpecsSystem Spec
Reply

 Run login command as Administrator





Thread Tools



Similar help and support threads for2: Run login command as Administrator
Thread Forum
Open Command Window Here as Administrator Tutorials
Run as administrator command has stopped working General Discussion
elevated command administrator password General Discussion
Solved How to Login As Administrator (not shown in login screen) General Discussion
Command Prompt won't Disable Administrator Account General Discussion
Solved I've lost my Run As Administrator command Performance & Maintenance
Problem open command Window(administrator) Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 06:57 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33