Hi All,

I have been searching for some code, with little success i may be just not searching right or not in the right place, but basically i just want some code to get thte current default printer of a machine, save it in script then call it later on in the script.

Im trying to make some vbscript that basically, maps a drive, ssaves the default printer, adds a printer and changes it to to default then loads an app, then when app closes, it removes network drive, and removes printer and sets default back to the original.

Possible?

Cheers,
Ry
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Have you tried the scripts that are provided by MS in your "System32" folder?

"prnmngr.vbs" may be the one you want?
Answered 09/29/2005 by: WiseUser
Fourth Degree Brown Belt

Please log in to comment
0
Give this a try. More than you need but you get the idea.
Google Scriptomatic. Cool toy with lots of uses.

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
For Each objItem in colItems

Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Default: " & objItem.Default
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "Local: " & objItem.Local
Wscript.Echo "Location: " & objItem.Location
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Network: " & objItem.Network
Wscript.Echo "PortName: " & objItem.PortName
Wscript.Echo "ServerName: " & objItem.ServerName
Wscript.Echo "SystemName: " & objItem.SystemName
Next
Answered 10/20/2005 by: Byoung4now
Senior Yellow Belt

Please log in to comment
0
Hi,

Use below script for set the printer as default printer.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Name = 'HP Color LaserJet 4700 PCL 6'")
For Each objPrinter in colInstalledPrinters
objPrinter.SetDefaultPrinter()
Next
Answered 09/29/2008 by: Gowri
Yellow Belt

Please log in to comment
0
Hi,

You can use below script for finding out the default printer using printer properties.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where Default = 'True'")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Next
Answered 09/30/2008 by: Gowri
Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity