• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Login Script - Verify Drive Letters and Local Printers

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.

Thanks
0
sneeri_c
Asked:
sneeri_c
1 Solution
 
ajsaastaCommented:
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
      Next
      
      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)
      Next
      Wscript.Echo "--------------------------------------------------"
End Function
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now