Registry setting for default printer


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.

Who is Participating?
gemartiConnect With a Mentor Commented:
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.
aperdonAuthor Commented:
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.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Here is a script that uses WMI to set the default printer. Maybe it will help....
Set the Default Printer

+++++++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
++++++++END SCRIPT+++++++++
This should be applicable in XP:

Changing a User's Default Printer in the Registry;en-us;156212

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

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. :(
aperdonAuthor Commented:
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.

aperdonAuthor Commented:
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?
>>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.
To change the default printer spool directory
aperdonAuthor Commented:
>>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.
aperdonAuthor Commented:
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:.
aperdonAuthor Commented:
Ok. I will test it. Thanx for the new info sofar again.
All Courses

From novice to tech pro — start learning today.