Jump to content

[Question] - List of printers stored on c:\?


Recommended Posts

Posted

When we setup up new computers in our multi-site location, we currently have the individual we are setting up the computer for, tell us, over the phone, a list of all the printer (local and network) that they currently have installed on their computer. We do the same thing with their network/mapped drives. We can access their c:\ drive remotely. My question is, are these two things stored in a file somewhere that we could just pull up and see the information?

Thanks,

Jason

Title Edited - Please follow new posting rules from now on.

--Zxian


Posted

For printers:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("<computer names here, comma-delimited>")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "Name: " & objItem.Name
WScript.Echo "ServerName: " & objItem.ServerName
WScript.Echo "ShareName: " & objItem.ShareName
WScript.Echo
WScript.Echo "DriverName: " & objItem.DriverName
WScript.Echo
WScript.Echo "Location: " & objItem.Location
WScript.Echo
WScript.Echo "Comment: " & objItem.Comment
Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

For mapped drives:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("<computer names here, comma-delimited>")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_MappedLogicalDisk", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "ProviderName: " & objItem.ProviderName
WScript.Echo "FileSystem: " & objItem.FileSystem
WScript.Echo
Next
Next


Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Posted

Just copy them into a new text file, and rename them to .vbs - then open a command prompt and run. No need for a compiler.

Also, printmig may work but it's a crapshoot against remote systems - stick to the vbscripts, they work 100% of the time.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...