Solved

Registry setting for default printer

Posted on 2004-04-28
13
20,468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 4

Expert Comment

by:scorpiia
ID: 10937107
HKey_Current_User\Printers
0
 
LVL 1

Author Comment

by:aperdon
ID: 10937330
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
ID: 10937437
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:gemarti
ID: 10937471
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
ID: 10937502
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
ID: 10937572
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
 
LVL 1

Author Comment

by:aperdon
ID: 10947118
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
ID: 10948910
>>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
ID: 10948936
To change the default printer spool directory
http://www.nthelp.com/351/spooldir.htm
0
 
LVL 1

Author Comment

by:aperdon
ID: 10948964
>>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
ID: 10949019
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
ID: 10950500
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
ID: 10950524
Ok. I will test it. Thanx for the new info sofar again.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to reinstall MS Office 2003 Standard Edition and need an ISO image or something.. 12 2,325
WinXP Unable to Print 4 121
Compatiable modem 2 74
Clone HDD in RAID1 10 158
Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

752 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