Announcement

Collapse
No announcement yet.

Deploy software

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

  • Deploy software

    If I want to create a login script to map drives and then paste a shortcut to the users desktop, can anyone give me pointers?

    This is what I understand so far:

    Code:
    set objNetwork = CreateObject("WScript.Network") 
    objNetwork.MapNetworkDrive "Z:" , "\\server\share"
    set WshShell = WScript.CreateObject("WScript.Shell")
    strDesktop = WshShell.SpecialFolders("Desktop")
    set oShellLink = WshShell.CreateShortcut(strDesktop & "\Network Share.lnk")
    oShellLink.TargetPath = "\\server\share"
    oShellLink.WindowStyle = 1
    oShellLink.IconLocation = "explorer.exe, 0"
    oShellLink.Description = "Network Share"
    oShellLink.WorkingDirectory = "\\share\server"
    oShellLink.Save
    How does this look so far? Any input?

    Thanks!
    Last edited by biggles77; 5th May 2009, 07:28. Reason: Wrap text in CODE

  • #2
    Re: Deploy software

    Hi,

    Why do you want to do that? what's your ultimate goal?
    If it is assigning different drives for different users, I'd start looking at Ifmember.exe for a more elegant solution.
    Caesar's cipher - 3

    ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

    SFX JNRS FC U6 MNGR

    Comment


    • #3
      Re: Deploy software

      Originally posted by L4ndy View Post
      Hi,

      Why do you want to do that? what's your ultimate goal?
      If it is assigning different drives for different users, I'd start looking at Ifmember.exe for a more elegant solution.
      No, I want to pretty much have the same shared drives for all users...

      For example have several drives mapped, one to S: for all scanned documents, one for I: for inventory, etc...

      Comment


      • #4
        Re: Deploy software

        you probably copied the script from here?
        http://forums.petri.com/showthread.php?t=2431
        Anyhow there is a small bug into it...

        set oShellLink = WshShell.CreateShortcut(strDesktop & "\Network Share.lnk")
        should be:
        set oShellLink = WshShell.CreateShortcut(strDesktop & "\Network Share.lnk")

        the & came from a move from PHPBB to Vbulletin
        Marcel
        Technical Consultant
        Netherlands
        http://www.phetios.com
        http://blog.nessus.nl

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"

        Comment


        • #5
          Re: Deploy software

          ok, will try that... thanks. If I want to do multiple, do I just rinse and repeat? Do I map each drive first then shortcut or map them all first and then build all shortcuts or does it really matter?

          Also, where on the server do I need to place the .vbs file and where in GP do I need to specify to run it?

          Thanks!
          Allen
          Last edited by chakotay2; 5th May 2009, 11:18.

          Comment


          • #6
            Re: Deploy software

            Originally posted by chakotay2 View Post
            If I want to do multiple, do I just rinse and repeat?
            For repeating code you can create subroutines or functions this will keep the script smaller. Subroutines can be called multiple time from the main part of the script.
            The sample below is using subroutines to map the drivse and one to create the shortcuts (optionally: there is one more subroutine that can change the display name of the mapped drive to hide the actual server\share names in explorer)

            Now, you'll just have to multiply the part that is between the 2 lines and edit the variables (colored blue in this sample).
            Code:
            Const CSIDL_DESKTOP = &H10
            
            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
            
            '-----------------------------------------------------------------------
            '                          Mapping 1
            '
            '# Map drive:
            sDriveLetter = "Z:"
            strUNC = "\\server\sharedfolder"
            Call MapDrive(sDriveLetter, strUNC)
            '# Create shortcut:
            strLNKPath = strDesktopFolder
            strLNKname = "Network Share 1"
            strTarget = "explorer.exe"
            strArguments = "/e,/root," & sDriveLetter & "\"
            Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
            '# Mapping's alias: (optional - remove 'rem' to activate this routine)
            rem Call NameMapping(strLNKname)
            '-----------------------------------------------------------------------
            
            ' next mappings and shortcuts....
            
            wscript.quit
            
            
            Sub CreateShortcut(sFolder, sName, sTarget, sArgs)
               With WshShell '(has a global scope)
                  With .CreateShortcut(sFolder &"\" & sName  &".LNK")
                     .TargetPath = sTarget
                     .Description = sName
                     .Arguments = sArgs
                     .IconLocation = "explorer.exe, 0"
                     .WindowStyle = 3  ' available: 1, 3 or 7 ( http://msdn.microsoft.com/en-us/library/w88k7fw2(VS.85).aspx )
                     .WorkingDirectory = "."
                     .Save
                  End With
               End With
            End Sub
            
            Sub MapDrive(DriveLetter, Share)
               On Error Resume Next
               With objNetwork
                  .MapNetworkDrive DriveLetter, Share, False
               End With
            End Sub
            
            Sub NameMapping(sAlias)
               With oShell
                  .NameSpace(sDriveLetter).Self.Name = sAlias
               End With
            End Sub
            _
            Originally posted by chakotay2 View Post
            Do I map each drive first then shortcut or map them all first and then build all shortcuts or does it really matter?
            Best is to map one drive and create its shortcut before going to the next drive because the script need for both actions at least one same defined variable. Also IMHO this way it will keep the script better understandable of what is doing.
            _
            Originally posted by chakotay2 View Post
            Also, where on the server do I need to place the .vbs file and where in GP do I need to specify to run it?
            A similar question about the scripts folder was asked in the scripting forum.
            The GPO should be linked to the OU were the users are, and the script configured as logonscript in the 'User Configuration' part of the GPO.


            \Rems
            Last edited by Rems; 6th May 2009, 14:50.

            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: Deploy software

              Thanks.... I am trying to post it to the netlogin and login script directory but it won't let me... I am NOT using the admin account but using an account with DC Admins membership... Looks like it works when I do it under the main admin account... is that the only acccount you can do it under or do I need to give more permission to my user account...?

              Comment


              • #8
                Re: Deploy software

                also I see it has to be in the scripts path as well as netlogon folder... Can anyone explain why it has to be in two places?

                Comment


                • #9
                  Re: Deploy software

                  It doesn't need to be in the netlogon folder unless you have legacy (pre windows 2000) clients that need to run the script. If all of your clients are W2K or later then the script will go into the appropriate scripts folder for the GPO it's linked to. You should not be manually copying it to that location, but rather you should be creating it through the GPMC, which will give you the appropriate access to the scripts folder.

                  Comment


                  • #10
                    Re: Deploy software

                    Good to know that I don't need two copies (netlogon doesn't need to be there), but I am going through group policy editor and it still won't give me access if I want to do anything in the correct folder. I can view but not save anything or save any changes.

                    Allen

                    Comment


                    • #11
                      Re: Deploy software

                      Sorry, maybe the 2nd question got lost in the text but how come I have to be logged on as Administrator (rather than Domain Admin) to do this? Is there a workaround?

                      Thanks,
                      Allen

                      Comment

                      Working...
                      X