Announcement

Collapse
No announcement yet.

Logon script help required

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

  • Logon script help required

    Hi,

    I am trying to apply the following logon script to a test user account but for some reason when I am logging on the mapped drive is not showing in Windows Explorer. The server and share are valid and I can access them under the run command but the script does not seem to work

    Script in use as follows;
    Code:
     
    ' Company Name
    '
    ' Information
    '
    ' Name:  Logon.vbs
    '  Purpose:  Logon Script
    ' OS:  All
    ' Type:  vbs
    ' Version: 1.0
    ' Date:  17 March 2012
    ' Name:  TC
    '
    ' Change Control (enter details here or revisions to the script)
    '
    '  Date             Who Revision Description of Change
    '  ------            ----- ---------- ---------------------
    '  17/03/2012   TC   1.0         Created
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Setup Script Variables
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Option Explicit 
    On Error Resume Next
    Dim UserObj, UserGroups, GroupObj, DriveLet, DrivePath 
    Dim WSHNetwork, WshShell
    Set WSHNetwork = WScript.CreateObject("WScript.Network")
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set UserObj = GetObject("WinNT://" & WshNetwork.UserDomain & "/" & WSHNetwork.UserName)
    InitGroups
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Clears Drive Mappings
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    WshNetwork.RemoveNetworkDrive "S:", True
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Setup Drives
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    If InGroup("Domain Users") Then
     MapNetdrv "S", "ggls01", "shared"
    End If
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'DO NOT EDIT Below here
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function:      MapDrive
    ' Arguments:     Drive Letter (with ":") and Share Name on ShareSvr:
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub MapNetdrv( strDrive, svrshare, strShare )
     DriveLet = strDrive & ":"
     DrivePath = "\\" & svrshare & "\" & strShare
     WSHNetwork.MapNetworkDrive DriveLet, DrivePath, False
    End Sub
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function:      InitGroups
    ' Arguments:     Checks group membership
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub InitGroups()
     UserGroups=""
     For Each GroupObj In UserObj.Groups 
      UserGroups=UserGroups & "[" & GroupObj.Name & "]"
     Next
    End Sub
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function: Check if user is in Group
    ' Arguments: Group to check membership of
    ' Note: Requires pre-initialization of UserGroups variant
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Function InGroup(strGroup)
     InGroup=False
     If InStr(UserGroups,"[" & strGroup & "]") Then
      InGroup=True
     End If
    End Function

    Any help would really be appreciated. Thank you

    T
    Last edited by Rems; 17th March 2012, 21:53.

  • #2
    Re: Logon script help required

    What happens if you run the script manually, after the user is logged on?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Logon script help required

      I could be wrong here:
      Sub MapNetdrv( strDrive, svrshare, strShare )
      DriveLet = strDrive & ":"
      DrivePath = "\\" & svrshare & "\" & strShare
      WSHNetwork.MapNetworkDrive DriveLet, DrivePath, False
      End Sub



      It looks like you're calling strDrive, svrshare, strShare, before they are declared as variables?
      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


      • #4
        Re: Logon script help required

        Good Call -- try removing "option explicit" at the head of the script or using DIM to create the variables in the first line of the function
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Logon script help required

          Basically there is nothing wrong with the script. The script that was posted should run succesfull. Although better changing the line
          If InStr(UserGroups,"[" & strGroup & "]") Then
          to
          If InStr(1, UserGroups,"[" & strGroup & "]",1) Then
          to make the group comparassing case unsensative.

          I like to know, like Ossian posted already, what happens if you run the script manually, after the user is logged on?
          What OS is on the test computer, and is the test user perhaps have administrator rights on the test computer?

          /Rems
          Last edited by Rems; 18th March 2012, 21:49.

          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


          • #6
            Re: Logon script help required

            Please excuse my inexperience here. How do I run the script manually. Currently I am trying to apply the script using the AD User account, Profile tab and then in the logon script box I am using 'login.vbs'

            Thank you

            Comment


            • #7
              Re: Logon script help required

              Once the user has logged on, navigate to the script folder and double click on it!
              Tom Jones
              MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
              PhD, MSc, FIAP, MIITT
              IT Trainer / Consultant
              Ossian Ltd
              Scotland

              ** Remember to give credit where credit is due and leave reputation points where appropriate **

              Comment


              • #8
                Re: Logon script help required

                Doh, I didn't think it would be that easy. I will give it a go when i can get back onto the server. Thanks

                Comment


                • #9
                  Re: Logon script help required

                  I have just tried that and it immediatley mapped the drive. I am not sure if it is relevant but I am logging onto a Remote Desktop Services server (Terminal Server).

                  Thanks

                  Comment


                  • #10
                    Re: Logon script help required

                    Originally posted by Toni Chaffin View Post
                    I have just tried that and it immediatley mapped the drive. I am not sure if it is relevant but I am logging onto a Remote Desktop Services server (Terminal Server).

                    Thanks
                    User Account Control (UAC) may prevent the logon script from appearing to work properly? When UAC is active and an administrative user logs on, Windows processes the logon scripts using the elevated token. The script actually works and maps the drive. However, Windows blocks the view of the mapped network drives because the desktop uses the limited token while the drives were mapped using the elevated token.

                    Is the test user a local admin on the test computer?

                    /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


                    • #11
                      Re: Logon script help required

                      No, the test user is just a Domain Users accounts with no special rights at all.

                      Any additional help would be appreciated as I need to get this working

                      Comment


                      • #12
                        Re: Logon script help required

                        Where is the script file located?
                        I have several clients with these kind of scripts. where the user is no local admin and uac enabled
                        just put in the netlogon folder.
                        In a production env never make your user local admin exept for testing.
                        Last edited by mhoogev; 25th March 2012, 20:16.

                        Comment

                        Working...
                        X