Solved

Registry setting for default printer

Posted on 2004-04-28
13
19,418 Views
Last Modified: 2011-08-18
Hi,

What is the registry setting for the current selected default printer.
It is some kind of combination of printer-name, port all contained in a ','-seperated string.

For the port in case of a file-port.
*Is it possible to change the port-directory by changing the registry setting.
*Is the printer-definition also affected when the registry-setting is changed.
*And is it possible to force this registry setting to be a named file instead of a directory.

Thanx,
Alexander
0
Comment
Question by:aperdon
  • 6
  • 6
13 Comments
 
LVL 4

Expert Comment

by:scorpiia
Comment Utility
HKey_Current_User\Printers
0
 
LVL 1

Author Comment

by:aperdon
Comment Utility
Not something like this for the current printer? But this one doesnot exist in my Registry.

HKCU:Software\Microsoft\Windows NT\CurrentVersion\Windows\Device

But when I debug through some code which reads from registry it reads from group="Windows" item="Device".


Let me check at home (at work now without any registry privileges) what is in this registry-dir you specified. Is there only the printer-definitions there or also some info about current default printer.
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
Here is a script that uses WMI to set the default printer. Maybe it will help....
Set the Default Printer
http://www.microsoft.com/technet/community/scriptcenter/printing/scrprn44.mspx

+++++++Start Script+++++++++++
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ScriptedPrinter'")
For Each objPrinter in colInstalledPrinters
    objPrinter.SetDefaultPrinter()
Next
++++++++END SCRIPT+++++++++
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
This should be applicable in XP:

Changing a User's Default Printer in the Registry
http://support.microsoft.com/default.aspx?scid=kb;en-us;156212

SUMMARY
There are times when you want to change the default printer of a user or group of users without having access to the user's (or users') computer(s). You can do this by making a registry entry.

The information in this article applies to:
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Professional
Microsoft Windows NT Workstation 3.5
Microsoft Windows NT Workstation 3.51

6/3/2003
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
BTW: The KEY that scorpia gives only directs you to the location that indicates what printers the user has set up, not the default printer. :(
0
 
LVL 1

Author Comment

by:aperdon
Comment Utility
I dont have "HKCU\\Software\Microsoft\Windows NT\CurrentVersion\Windows:Device" in my registry in my XP. Yet I am able to query the registry for "Windows:Device" to get the current default printer. Very confusing. You have this key in ur XP registry?

Will the script as you provided work in VBA? Can I just use Get/Set ProfileString Win32 Api's to do the trick?

The "string" defined by Device denotes : <name>,<driver>,<port>

What can I do with this <port>. Can I force this port to send output to a named-filename.Or is <port> always a directory. Will changing the <port> part for the default printer afftect the printer settings as defined for the same named printer in HKCU\\Printers.

Indeed, I assumed that scorpia-s KEY only is for the printer definitions.

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:aperdon
Comment Utility
You are right about the key. I found it. I cant see any reason why i did it not see it time over time..... Must have looked at 1000 times and always overlooked it.

I played around with the default printer key. Changing port part does not affect to which dir the output-file is written.
But however, there is a Port key inside the printer-definition key. I will try that one.

Do you have any experience with changing port-spool-directories?
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
>>Will the script as you provided work in VBA? Can I just use Get/Set ProfileString Win32 Api's to do the trick?
You can save it as a VBS script and it should run in XP with no problems. If you do have a problem then make sure the Windows Management Instrumentation Service is running (START | RUN | SERVICES.MSC)


>>What can I do with this <port>.
I think you can either send the print job to a local printer port, such as LPT1 or to a network shared printer. I think the only way to send a print job to a file is to select that option when prompted by the print dialog.

>>Do you have any experience with changing port-spool-directories?
Yes. It is a registry hack as well. You have to tell the system where the new spool directory is located.
0
 
LVL 21

Expert Comment

by:gemarti
Comment Utility
To change the default printer spool directory
http://www.nthelp.com/351/spooldir.htm
0
 
LVL 1

Author Comment

by:aperdon
Comment Utility
>>Do you have any experience with changing port-spool-directories?
Yes. It is a registry hack as well. You have to tell the system where the new spool directory is located.

So without creating a new port. Just change the Port key to whatever spool-dir. Right?
Can you share your experiences in this, especially if it comes to named-file spooling. That is: Can I specify an output-file-name in the Port-key and to force the spooler to write to that file.
0
 
LVL 1

Author Comment

by:aperdon
Comment Utility
Ok. I see you posted another comment while I was typing mine.

Any experience with this SpoolDirectory? This is like 'Port' right, in case of a file-based port. SpoolDirectory probably wont be used by other type of port-printing like printing to for example to LPT1:.
0
 
LVL 21

Accepted Solution

by:
gemarti earned 100 total points
Comment Utility
My only experience with SpoolDirectory is that on my print server I changed the spool directory to a different drive so as to not create problems on the drive that my system is installed on. I'm not exactly sure of what you are asking. If your wanting to print to file then I believe the file is stored in that spool file directory until it is released, but I'm not real sure about that.
0
 
LVL 1

Author Comment

by:aperdon
Comment Utility
Ok. I will test it. Thanx for the new info sofar again.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now