Run login command as Administrator

Page 1 of 2 12 LastLast

  1. Posts : 76
    XP, Vista, W7, all flavors
       #1

    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/W7 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 Computer


  2. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #2

    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 Computer


  3. Posts : 76
    XP, Vista, W7, all flavors
    Thread Starter
       #3

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


  4. Posts : 76
    XP, Vista, W7, all flavors
    Thread Starter
       #4

    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 Computer


  5. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #5

    ultralame said:
    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 Computer


  6. Posts : 76
    XP, Vista, W7, all flavors
    Thread Starter
       #6

    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 Computer


  7. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #7

    ultralame said:
    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 Computer


  8. Posts : 76
    XP, Vista, W7, all flavors
    Thread Starter
       #8

    > 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 Computer


  9. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #9

    ultralame said:
    > 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 Computer


  10. Posts : 76
    XP, Vista, W7, all flavors
    Thread Starter
       #10

    >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 Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 03:44.
Find Us