Announcement

Collapse
No announcement yet.

Random users not mapping network drive at logon via script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Random users not mapping network drive at logon via script

    As title really, it seems that at random various users do not get various network drives mapped at log on.

    The mapping is handled by simple log on scripts that are assigned via GP and are slightly different for each OU. Here is an example, for our accounts dept:

    Code:
    REM ***** DEBUG: Ping Delay *****
    
    ping server
    
    REM ***** map shared group drives *****
    
    NET USE S: \\server\ACCOUNTS
    NET USE G: \\server\GENERAL
    NET USE I: \\server\SSSL
    NET USE X: \\server\ATTACHMENTS
    
    REM ***** map personal drive *****
    
    NET USE H: /home
    
    REM ***** force GP update *****
    
    gpupdate /force
    
    REM ***** Update hosts file *****
    
    copy G:\hosts C:\WINDOWS\SYSTEM32\DRIVERS\ETC
    
    REM ***** map unique user drives *****
    
    :1
    IF %USERNAME% == user GOTO 2
    IF %USERNAME% == user GOTO 3
    EXIT
    :2
    NET USE P: \\server\PAYROLL
    EXIT
    :3
    NET USE M: \\server\COP
    EXIT
    Now, more often than not, the home drive will be mapped no problem. However, the other drives will not be mapped. I've added the ping, just to ensure the PC is established on the network and make sure it can actually see the server. The script runs and ping is fine, but still some drives do not map! If I then run the script after logon, its fine!

    At log out, another script is run, disconnecting all the mapped drives, for various reasons.

    So. I'm pretty sure the batch file is fine, as usually it works for most users, but a few do have issues. Any idea's what could be causing this? Could it be linked to faulty network equipment, maybe a NIC or cable?
    James
    MCP

  • #2
    Re: Random users not mapping network drive at logon via script

    Hi,

    I prefer to call a vbs file instead of using BATCH files...


    but for your problem try to change the net use command to something like this:

    Code:
    NET USE S: \\server\ACCOUNTS > NUL
    NET USE G: \\server\GENERAL > NUL
    NET USE I: \\server\SSSL > NUL
    NET USE X: \\server\ATTACHMENTS > NUL

    Comment


    • #3
      Re: Random users not mapping network drive at logon via script

      James,

      What OS in on these clients?
      Is this the complete batch. And, is the batch invoked drectly by the GPO or perhaps lauched from within another logon script?

      Enable the Group Policy setting 'Always wait for the network at computer startup and logon' (Not required if the logon script was set at the user object).

      Is loopback processing used in one of the GPOos?

      Try also in the batch to disconnect all possible existing mappings before making mappings.
      Then use "\Persistent:No" for mapping the drives (then you also don't have to programmatically disconnect at logoff)

      sample:
      Code:
      @echo off
      
      CALL:LOGONBATCH > "%TEMP%.\DRIVEMAPPINGS.LOG" 2>&1
      GOTO:EOF  the code in orange make the batch write a log file to the user's temp folder with the last results.
      :LOGONBATCH 
      
      Set "$FSVR=Server'sFullDNSname"
      
      >Nul Net use * /D /Y 
      <nul (Set /P j=Wait ) & call:waitfornetwork
      
      goto:endsub1
      :waitfornetwork
      Set /a iCnt +=1
      (ping.exe -n 2 -w 100 %$FSVR% |find/i "TTL=")>nul &&(
         echo\...Connection!) ||(if %iCnt% LEQ 20 (
         <nul (Set /P j=.)&goto waitfornetwork))
      echo. & exit /b
      :endsub1
      
      echo Results Mapping S:
      NET.exe USE S: "\\%$FSVR%\ACCOUNTS" /P:NO
      
      echo Results Mapping G:
      NET.exe USE G: "\\%$FSVR%\GENERAL" /P:NO
      
      echo Results Mapping I:
      NET.exe USE I: "\\%$FSVR%\SSSL" /P:NO
      
      echo Results Mapping X:
      NET.exe USE X: "\\%$FSVR%\ATTACHMENTS" /P:NO
      
      ::  cut  . . .

      \Rems
      Last edited by Rems; 17th April 2010, 19:18.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Random users not mapping network drive at logon via script

        Originally posted by YoungCoder View Post
        Code:
        NET USE S: \\server\ACCOUNTS > NUL
        Pray tell me, what good would redirecting net command's output to null device do?

        OP: You could redirect net cmd output to a log file to see if there are any error messages.

        Maybe deleting the network drive fails? Try log statements in the logoff script too. In addition, you could try mapping the drives with /persistent:no switch, so that connections will not stick.

        -vP

        Comment


        • #5
          Re: Random users not mapping network drive at logon via script

          outputting to a log is a good bet for now - it should allow you to see what's happening.

          I trapped a scenario where we didn't have enough licenses like this..
          Please do show your appreciation to those who assist you by leaving Rep Point https://www.petri.com/forums/core/im.../icon_beer.gif

          Comment


          • #6
            Re: Random users not mapping network drive at logon via script

            Originally posted by tehcamel View Post
            outputting to a log is a good bet for now - it should allow you to see what's happening.

            I trapped a scenario where we didn't have enough licenses like this..
            An excellent suggestion made by vonPryz and tehcamel.
            Therefore I've now added the orange colored text to the batch.
            The code in orange does make the batch write a log to the user's temp folder containing the last results. (The file will be overwritten at each logon of the same user on the computer).

            \Rems
            Last edited by Rems; 17th April 2010, 19:44.

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment


            • #7
              Re: Random users not mapping network drive at logon via script

              Apologies for not getting back sooner, it has been a crazy year here and this was pushed to the back of the queue...

              I am taking on board the suggestions here and will try them out.

              Rems, the OS is Win XP Pro. This is the complete batch. Batch is applied directly to the OU. the is another batch that runs prior to this one, as a general batch for everyone on the domain. Mapped drives are disconnected at log off. 'Always wait for the network at computer startup and logon' was tested and made no difference at all.

              I will try logging to see if that gives an insight. will also use persistent no and disregard the log off disconnect.
              James
              MCP

              Comment


              • #8
                Re: Random users not mapping network drive at logon via script

                OK have been running this for a while now.

                In the logs of those having connection problems, error 53 is seen.
                James
                MCP

                Comment


                • #9
                  Re: Random users not mapping network drive at logon via script

                  could you paste a chunk of the log where it's relevant ?

                  also - what happens if you try the FQDN of the server, rather than just the server name ?

                  also, take a look at this, primarily from step 4 for clearing cached or saved passwords
                  http://forum.synology.com/wiki/index..._network_drive

                  You could also try adding net use * /d /y to the start of your script, unless you already added it with rem's script
                  Please do show your appreciation to those who assist you by leaving Rep Point https://www.petri.com/forums/core/im.../icon_beer.gif

                  Comment


                  • #10
                    Re: Random users not mapping network drive at logon via script

                    On those having connection problems run: rundll32.exe keymgr.dll, KRShowKeyMgr
                    Or better, run: cmdkey.exe /list
                    (copy cmdkey.exe from a windows server 2003 machine to %windir% on the client)

                    Are there saved credentials that someway pointing to the server found on these clients?


                    \Rems

                    This posting is provided "AS IS" with no warranties, and confers no rights.

                    __________________

                    ** Remember to give credit where credit's due **
                    and leave Reputation Points for meaningful posts

                    Comment

                    Working...
                    X