Page 1 of 1 1
Topic Options
#129237 - 2004-11-10 05:15 PM Getting Default Printer
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi All,

Was doing a search for getting the default Printer of the logged on PC, but I couldn't find much.

Here is a quick script that may help someone.

Thanks

Code:

? GetDefaultPrinter

Function GetDefaultPrinter()
$oShell = CreateObject("WScript.Shell")
$sRegVal = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
$sDefault = ""
$sDefault = $oShell.RegRead($sRegVal)
$sDefault = Left($sDefault ,InStr($sDefault, ",") - 1)
$GetDefaultPrinter = $sDefault
EndFunction



Edited by Richie19Rich77 (2004-11-10 05:15 PM)

Top
#129238 - 2004-11-10 05:30 PM Re: Getting Default Printer
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Or you could just do this:

Code:
 
? ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")



Doh how stupid of me

Top
#129239 - 2004-11-11 01:04 AM Re: Getting Default Printer
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Or use this UDF: GetDefaultPrinter() - Returns default printer
_________________________
There are two types of vessels, submarines and targets.

Top
#129240 - 2004-11-11 10:19 AM Re: Getting Default Printer
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Now come on that would have been way too easy for me to do a search.

Thanks

Top
#129241 - 2004-11-11 10:46 AM Re: Getting Default Printer
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
_________________________



Top
#129242 - 2004-11-11 09:07 PM Re: Getting Default Printer
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hey Richie boy...

Think you could fix your signature. Doesn't display correctly.

If that is your joke, sorry, but looks FUGLY

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.054 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org