Announcement

Collapse
No announcement yet.

Script not working on Windows 7 - 64 bit

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

  • Script not working on Windows 7 - 64 bit

    This script works great on Windows XP 32 bit. On our new Windows 7 64 bit machines it puts the icon on the desktop but does not actually map the drive. Any suggestions?

    Thanks,
    Allen

    Code:
    Const CSIDL_DESKTOP = &H10
    Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
    Dim strLNKPath, strLNKname
    Dim strTarget, strArguments
    Dim sDriveLetter, strUNC
    Dim objNetwork: set objNetwork = CreateObject("WScript.Network")
    Dim WshShell: set WshShell = CreateObject("WScript.Shell")
    Dim oShell: Set oShell = CreateObject("Shell.Application")
    Dim oDesktop: Set oDesktopFolder = oShell.Namespace(CSIDL_DESKTOP)
    Dim strDesktopFolder: strDesktopFolder = oDesktopFolder.Self.path
    'duplicate part between ---- sDriveLetter = "Z:"  strUNC = "\\server\sharedfolder"  strLNKname = "Network Share 1"
    '-----------------------------------------------------------------------
    '                          Mapping 1
    '
    '# Map drive:
    sDriveLetter = "N:"
    strUNC = "\\LPVSERVER\Users Documents\Inventory"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Inventory"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    '-----------------------------------------------------------------------
    '                          Mapping 2
    '
    '# Map drive:
    sDriveLetter = "R:"
    strUNC = "\\LPVSERVER\Users Documents\Receptionists"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Receptionist"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    '-----------------------------------------------------------------------
    '                          Mapping 3
    '
    '# Map drive:
    sDriveLetter = "S:"
    strUNC = "\\LPVSERVER\Users Documents\Digtal Sender"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Scanner"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    '                          Mapping 4
    '
    '# Map drive:
    sDriveLetter = "V:"
    strUNC = "\\LPVSERVER\Users Documents\Doctors"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Veterinarians"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    '-----------------------------------------------------------------------
    '                          Mapping 5
    '
    '# Map drive:
    sDriveLetter = "O:"
    strUNC = "\\LPVSERVER\Users Documents\DigitalDental"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Dental"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    '-----------------------------------------------------------------------
    '                          Mapping 6
    '
    '# Map drive:
    sDriveLetter = "G:"
    strUNC = "\\LPVSERVER\Users Documents\Groomers"
    Call MapDrive(sDriveLetter, strUNC)
    '# Create shortcut:
    strLNKPath = strDesktopFolder
    strLNKname = "Groomers"
    strTarget = "explorer.exe"
    strArguments = "/e,/root," & sDriveLetter & "\"
    Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
    '# Mapping's alias: (optional - remove 'rem' to activate this routine)
    Call NameMapping(strLNKname)
    '-----------------------------------------------------------------------
    ' next mappings and shortcuts....
    wscript.quit
    
    Sub CreateShortcut(sFolder, sName, sTarget, sArgs)
       On Error Resume Next
       With WshShell '(has a global scope)
          With .CreateShortcut(sFolder &"\" & sName  &".LNK")
             .TargetPath = sTarget
             .Description = sName
             .Arguments = sArgs
             .IconLocation = "shell32.dll, 9"
             .WindowStyle = 3
             .WorkingDirectory = "."
             .Save
          End With
       End With
       If err.number = 0 OR err.Number = -2147024864 Then
          Exit Sub  ' ignore 80070020 errors 
       Else
          wscript.echo "Done Loading Shorcuts - Please press OK to continue - ALC" _
                & vbNewLine & "[" & err.number & "]", err.description
       End If
    End Sub
    Sub MapDrive(DriveLetter, Share)
       On Error Resume Next
       With objNetwork
          .MapNetworkDrive DriveLetter, Share, False
       End With
       If err.number = 0 OR err.Number = -2147024811 Then
          Exit Sub  ' ignore 80070055 errors 
       Else
          wscript.echo "Done Loading Shorcuts - Please press OK to continue - ALC" _
                & vbNewLine & "[" & err.number & "]", err.description 
       End If
    End Sub
    Sub NameMapping(sAlias)
       On Error Resume Next
       With oShell
          .NameSpace(sDriveLetter).Self.Name = sAlias
       End With
    End Sub
    Last edited by Rems; 1st June 2010, 19:58.

  • #2
    Re: Script not working on Windows 7 - 64 bit

    No errors displayed?
    How about putting in some debugging messages to see where it falls over
    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: Script not working on Windows 7 - 64 bit

      No error messages. What should I put in to debug?

      Comment


      • #4
        Re: Script not working on Windows 7 - 64 bit

        Does the account you're testing with has local admin rights? Then read here for the workarounds you can try:

        - configure launchapp.wsf to postpone the execution of a logon script
        - configure the EnableLinkedConnections registry value. Use this workaround at your own risk.
        or,
        - disable UAC. Use this workaround at your own risk.


        \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


        • #5
          Re: Script not working on Windows 7 - 64 bit

          I used the EnableLinkedConnections fix and it works great... Too bad M$ didn't do something that this could be turned on via GP.

          Thanks for the help!

          Comment


          • #6
            Re: Script not working on Windows 7 - 64 bit

            Well done!
            For future reference, a lot of quick debugging is done by output statements at critical points in your script, so you can see how far you are getting before things go wrong.
            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


            • #7
              Re: Script not working on Windows 7 - 64 bit

              Originally posted by chakotay2 View Post
              I used the EnableLinkedConnections fix and it works great... Too bad M$ didn't do something that this could be turned on via GP.

              Thanks for the help!
              FYI - you can deploy registry keys via GPO.

              Comment


              • #8
                Re: Script not working on Windows 7 - 64 bit

                If I do so will it mess up my Windows XP machines if they are in the same GPO?

                Comment


                • #9
                  Re: Script not working on Windows 7 - 64 bit

                  Use a WMI filter by OS
                  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


                  • #10
                    Re: Script not working on Windows 7 - 64 bit

                    not quite how to do that so lemme google and see if I can figure it out.

                    Comment


                    • #11
                      Re: Script not working on Windows 7 - 64 bit

                      Still not working. Here is the launchapp.wsf:

                      Code:
                      ' A constant that specifies the flag in RegisterTaskDefinition.
                      const FlagTaskCreate = 2 
                      ' A constant that specifies an executable action.
                      const LogonTypeInteractive = 3 
                      If WScript.Arguments.Length <> 1 Then
                      WScript.Echo "Usage: cscript launchapp.wsf <AppPath>" 
                      WScript.Quit
                      End If
                      strAppPath = WScript.Arguments(0)
                      '********************************************************
                      ' Create the TaskService object.
                      '********************************************************
                      Set service = CreateObject("Schedule.Service")
                      call service.Connect()
                      strTaskName = "Launch App As Interactive User"
                      '********************************************************
                      ' Get a folder to create a task definition in. 
                      '********************************************************
                      Dim rootFolder
                      Set rootFolder = service.GetFolder("\")
                      'Delete the task if already present
                      On Error Resume Next
                      call rootFolder.DeleteTask(strTaskName, 0)
                      Err.Clear
                      '********************************************************
                      ' Create the new task
                      '********************************************************
                      Dim taskDefinition
                      Set taskDefinition = service.NewTask(0) 
                      '********************************************************
                      ' Create a registration trigger.
                      '********************************************************
                      Dim triggers
                      Set triggers = taskDefinition.Triggers
                      Dim trigger
                      Set trigger = triggers.Create(TriggerTypeRegistration) 
                      '***********************************************************
                      ' Create the action for the task to execute.
                      '***********************************************************
                      ' Add an action to the task. The action executes the app.
                      Dim Action
                      Set Action = taskDefinition.Actions.Create( ActionTypeExecutable )
                      Action.Path = strAppPath
                      WScript.Echo "Task definition created. About to submit the task..."
                      '***********************************************************
                      ' Register (create) the task.
                      '***********************************************************
                      call rootFolder.RegisterTaskDefinition( _
                      strTaskName, taskDefinition, FlagTaskCreate, _
                      ,, LogonTypeInteractive)
                      WScript.Echo "Task submitted."
                      </script>
                      </job>
                      and here is the logon.vbs that works great on windows xp:

                      Code:
                      Const CSIDL_DESKTOP = &H10
                      Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
                      Dim strLNKPath, strLNKname
                      Dim strTarget, strArguments
                      Dim sDriveLetter, strUNC
                      Dim objNetwork: set objNetwork = CreateObject("WScript.Network")
                      Dim WshShell: set WshShell = CreateObject("WScript.Shell")
                      Dim oShell: Set oShell = CreateObject("Shell.Application")
                      Dim oDesktop: Set oDesktopFolder = oShell.Namespace(CSIDL_DESKTOP)
                      Dim strDesktopFolder: strDesktopFolder = oDesktopFolder.Self.path
                      'duplicate part between ---- sDriveLetter = "Z:"  strUNC = "\\server\sharedfolder"  strLNKname = "Network Share 1"
                      '-----------------------------------------------------------------------
                      '                          Mapping 1
                      '
                      '# Map drive:
                      sDriveLetter = "N:"
                      strUNC = "\\LPVSERVER\Users Documents\Inventory"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Inventory"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      '-----------------------------------------------------------------------
                      '                          Mapping 2
                      '
                      '# Map drive:
                      sDriveLetter = "R:"
                      strUNC = "\\LPVSERVER\Users Documents\Receptionists"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Receptionist"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      '-----------------------------------------------------------------------
                      '                          Mapping 3
                      '
                      '# Map drive:
                      sDriveLetter = "S:"
                      strUNC = "\\LPVSERVER\Users Documents\Digtal Sender"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Scanner"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      '                          Mapping 4
                      '
                      '# Map drive:
                      sDriveLetter = "V:"
                      strUNC = "\\LPVSERVER\Users Documents\Doctors"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Veterinarians"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      '-----------------------------------------------------------------------
                      '                          Mapping 5
                      '
                      '# Map drive:
                      sDriveLetter = "O:"
                      strUNC = "\\LPVSERVER\Users Documents\DigitalDental"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Dental"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      '-----------------------------------------------------------------------
                      '                          Mapping 6
                      '
                      '# Map drive:
                      sDriveLetter = "G:"
                      strUNC = "\\LPVSERVER\Users Documents\Groomers"
                      Call MapDrive(sDriveLetter, strUNC)
                      '# Create shortcut:
                      strLNKPath = strDesktopFolder
                      strLNKname = "Groomers"
                      strTarget = "explorer.exe"
                      strArguments = "/e,/root," & sDriveLetter & "\"
                      Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
                      '# Mapping's alias: (optional - remove 'rem' to activate this routine)
                      Call NameMapping(strLNKname)
                      '-----------------------------------------------------------------------
                      ' next mappings and shortcuts....
                      wscript.quit
                      
                      Sub CreateShortcut(sFolder, sName, sTarget, sArgs)
                         On Error Resume Next
                         With WshShell '(has a global scope)
                            With .CreateShortcut(sFolder &"\" & sName  &".LNK")
                               .TargetPath = sTarget
                               .Description = sName
                               .Arguments = sArgs
                               .IconLocation = "shell32.dll, 9"
                               .WindowStyle = 3
                               .WorkingDirectory = "."
                               .Save
                            End With
                         End With
                         If err.number = 0 OR err.Number = -2147024864 Then
                            Exit Sub  ' ignore 80070020 errors 
                         Else
                            wscript.echo "Done Loading Shorcuts - Please press OK to continue - ALC" _
                                  & vbNewLine & "[" & err.number & "]", err.description
                         End If
                      End Sub
                      Sub MapDrive(DriveLetter, Share)
                         On Error Resume Next
                         With objNetwork
                            .MapNetworkDrive DriveLetter, Share, False
                         End With
                         If err.number = 0 OR err.Number = -2147024811 Then
                            Exit Sub  ' ignore 80070055 errors 
                         Else
                            wscript.echo "Done Loading Shorcuts - Please press OK to continue - ALC" _
                                  & vbNewLine & "[" & err.number & "]", err.description 
                         End If
                      End Sub
                      Sub NameMapping(sAlias)
                         On Error Resume Next
                         With oShell
                            .NameSpace(sDriveLetter).Self.Name = sAlias
                         End With
                      End Sub
                      I have also attached screenshots of my Group Policy settings, directory location as well as WMI filter.... Trying to "help you, help me"...
                      Attached Files

                      Comment


                      • #12
                        Re: Script not working on Windows 7 - 64 bit

                        Am I doing this the hard way (scripts)?

                        Just found this:

                        http://blogs.technet.com/b/grouppoli...ng-drives.aspx

                        Will this work on XP or just Vista/Windows 7/2008 machines? and is it a better (easier) way?

                        Comment


                        • #13
                          Re: Script not working on Windows 7 - 64 bit

                          Originally posted by chakotay2 View Post
                          Am I doing this the hard way (scripts)?

                          Just found this:

                          http://blogs.technet.com/b/grouppoli...ng-drives.aspx

                          Will this work on XP or just Vista/Windows 7/2008 machines? and is it a better (easier) way?
                          Wow, this works like a champ on Windows 7 w/o any hassle of scripting...

                          Drives are mapping great now and it's easy! Thanks for everyone's help.

                          Comment

                          Working...
                          X