Login Script - Verify Drive Letters and Local Printers

Posted on 2005-04-27
Medium Priority
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

Accepted Solution

ajsaasta earned 2000 total points
ID: 13880795
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

578 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