Login Script - Verify Drive Letters and Local Printers

Posted on 2005-04-27
Last Modified: 2011-04-14
I have a VBS login script which is run via a GPO. Everything is working great. (I know good for me :) )

Anyway, I would like to add some code to the vbscript to:
1) Search to see if a specific drive letter already exists or if it is currently mapped to something  
2) Determine if the user has a local printer. I do not want to set the default to a network printer if they have a local one.

Any help is greatly appreciated.

Question by:sneeri_c
    1 Comment
    LVL 4

    Accepted Solution

    This will help on No. 1.

    Function DoCheck()
          ' ----- Fixed disks
          strComputer = "."
          Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
          Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DriveType=3")
          Wscript.Echo "Fixed disks:" & vbNewline
          Wscript.Echo "Drive" & vbTab & "Volume Name" & vbNewline & "--------------------------------------------------"
          For each objDisk in colDisks
                Wscript.Echo objDisk.Name & vbTab & objDisk.VolumeName
          Wscript.Echo "--------------------------------------------------" & vbNewline

          ' ----- Mappings      
          Set WshNetwork = WScript.CreateObject("WScript.Network")
          Set AllDrives = WshNetwork.EnumNetworkDrives()

          Wscript.Echo "Mapped drives:" & vbNewline
          Wscript.Echo "Local" & vbTab & "Remote" & vbNewline & "--------------------------------------------------"
          For i = 0 To AllDrives.Count - 1 Step 2
                Wscript.Echo AllDrives.Item(i) & vbTab & AllDrives.Item(i+1)
          Wscript.Echo "--------------------------------------------------"
    End Function

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
    The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now