Archive: Reading/Setting Default Printer


Reading/Setting Default Printer
Hi all,

I was wondering if anyone knows how to find and change a user's default printer using NSIS? Preferably without using command line tools, since my script is attempting a printer migration for all users on the PC directly via the registy.

My search didnt come up with any results.

Thanks,
- Dennis Feiock


You can call SetDefaultPrinter and GetDefaultPrinter using the System plug-in.

System::Call 'winspool::GetDefaultPrinter(t .r0, *i ${NSIS_MAX_STRLEN})'
MessageBox MB_OK $0
But those aren't supported on Windows 9x. I think on Windows 9x, this is saved in WIN.INI.

kichik,

Thanks for the input. I'm afraid that system calls in this scenario are not going to work out well.

My script migrates the printers for all users on the PC using the EnumUsersReg include and converting them under HKU\SID\Printers\Connections.

I will be using PsExec to push out the executable, which runs it as the Local Service account. Thus, system calls would only make the necessary changes for that one account.

Any ideas specific registry changes that can be made to have the same result?

Thanks,
- Dennis


First Google result for "default printer registry" came up is:

http://www.winguides.com/registry/display.php/279/

That seems like what you're looking for.