Login Script to Map Users Personal Drive

Home Forums Scripting General Scripting Login Script to Map Users Personal Drive

This topic contains 9 replies, has 6 voices, and was last updated by  PaulH 11 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts

  • vampiel_6
    Member
    #123073

    Hello to all the experts. Just wish to know that is the below login script workable?

    ECHO ON
    SET PATH I: \ServerUSERS%USERNAME%

    My intention is to create a personal drive of every users, i have in their pc when they reboot the pc.
    I believe the %USERNAME% will be tied to the login ID of that particular pc. eg.

    My login id of my PC is vampiel. So my this logon script will be:

    ECHO ON
    SET PATH I: \S2003USERSvampiel

    Is this correct?

    Please adivce me


    PaulH
    Member
    #294113

    Re: Login Script to Map Users Personal Drive

    No, using SET PATH is not correct. Please lookup the help for NET USE instead by typing NET USE /?

    What SET PATH does is it creates a long environment variable which is a series of paths that cause the operating system to look in those locations when running a program (if the program’s path is not explicitly specified). So for example, if C:MyApps is part of your system’s PATH environment, you could open a command prompt and run an executable that resides in the C:MyApps folder without having to tell the perating system whereabouts that executable lives. the OS just ‘knows’ where to look because C:MyApps is on the “PATH”. So SET PATH does not map drive letters.

    Contrast that with NET USE which will map a resource to a letter, and it can even map printers (for example to LPT1: ) as well as shared folders (to drive letters). So what you need is

    Code:
    NET USE I: \ServerUSERS%USERNAME%

    You may also like to consider using NET USE I: /DELETE first, so as to get rid of any unwanted I: drive letters that may have existed before, otherwise an old I: mapping will break things.

    #219366

    Re: Login Script to Map Users Personal Drive

    further to Paul’s excellent post, I would put a short (1 sec or so) delay between the /delete and the /use. In my experience the /delete takes a little while to complete and the /use bombs if it hasn’t done.


    vampiel_6
    Member
    #286227

    Re: Login Script to Map Users Personal Drive

    Thanks paul for your excellent explaination…. I got it.

    so i assume the full logon script command will be

    Echo On
    NET USE I: \S2003USERS%USERNAME%

    S2003 -> Server name
    USERS -> Folder name

    M i correct to say that?

    Sorry i am quite a Scripting Idiot.

    Anyway i really appreciate your help.


    PaulH
    Member
    #294114

    Re: Login Script to Map Users Personal Drive

    Yes, you got it – also don’t forget that the folders all have to exist!

    Also, consider the net use I: /delete line and Tom’s advice on the delay too. Just suggestions – good luck! Oh, and test it plenty :razz:


    sorinso
    Member
    #265024

    Re: Login Script to Map Users Personal Drive

    If you want to develop your script further, I suggest you looking at Andrew Hinson’s script in this thread: http://forums.petri.com/showpost.php?p=62611&postcount=1 . It contains a check to see if the letter is in use, for instance, thus you will not need to use the net use I: /delete command.

    #219369

    Re: Login Script to Map Users Personal Drive

    or, when you map it, use this:

    NET USE I: \S2003USERS%USERNAME% /PERSISTENT:NO

    This means it goes away when you log off…


    Rems
    Moderator
    #226318

    Re: Login Script to Map Users Personal Drive

    Stonelaughter;64706 wrote:
    In my experience the /delete takes a little while to complete and the /use bombs if it hasn’t done.

    Maybe Start /Wait for executing Net.exe can provide the nesserary delay.

    echo on
    @Start /Wait /B NET.exe USE * /delete

    @NET USE I: \ServerUSERS%USERNAME% /persistent:no[/CODE]

    – [url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true] net use[/url]
    – [url=http://www.ss64.com/nt/start.html] start/w[/url]
    – [url=http://www.robvanderwoude.com/wait.html] “wait” in a batch[/url]

    Rem[CODE]echo on
    @Start /Wait /B NET.exe USE * /delete

    @NET USE I: \ServerUSERS%USERNAME% /persistent:no[/CODE]

    net use
    start/w
    “wait” in a batch

    Rem


    PaulH
    Member
    #294115

    Re: Login Script to Map Users Personal Drive

    Oops! I made a typo:

    PaulH;64721 wrote:
    netuse I: /delete

    should be actually net use I: /delete

    I missed out the space there between net and use but I bet you spotted that !

    Have a good weekend.


    biggles77
    Spectator
    #206521

    Re: Login Script to Map Users Personal Drive

    Looks alright to me (now). :mrgreen:

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.