Jump to content


h4x0r

Completely out of ideas...setting the default printer from TS

Recommended Posts

One of the things we have implemented with our in-place refresh is re-installing printers with a powershell script...yes, I know there are ways to do this with GPO...I'm not going into the details, but suffice to say that GPO printer installs are not an option right now (unfortunately). But here's what I have run into...in my powershell, I'm executing the rundll32 printui.dll command. The script loops through and collects info on the printers which were installed and then choses the appropriate printer from that list to set as default, again using the rundll32 printui command. I have to use the rundll32 method because the prnmngr.vbs requires elevation to install a printer, which I can't get through a TS (at least not easily).

 

If I simply run the script by itself then things work perfectly...all printers install and the default is set at the end. However, when running it from a TS, the only thing which doesn't work is setting the default printer. Since it wasn't working in my PS TS step, I figured I would hard-code it in with a Run Command Line step, passing a TS variable in my PS code. That didn't work either. I even setup a VBScript to set the default printer, but that did not work.

 

I'm out of ideas at this point, and I don't know why it wouldn't be working from a TS other than it might be because it is running under a system context instead of a user? I don't know...I'm just stumped right now, and I'm too close to the project right now to think outside of the box at the moment. Any input would be appreciated. thanks.

Share this post


Link to post
Share on other sites


Thanks for the response, Peter...I feel rather like an idiot, because I should have tested that already. I will do that today and report back what I find.

Share this post


Link to post
Share on other sites

Well we have a winner...system context will not set the default printer...which makes sense, I guess, being as that is typically a per-user setting. Headed back to google now, but I'll go ahead and ask here as well...

 

So how would I run a script in a TS under the user context?

Share this post


Link to post
Share on other sites

Well we have a winner...system context will not set the default printer...which makes sense, I guess, being as that is typically a per-user setting. Headed back to google now, but I'll go ahead and ask here as well...

 

So how would I run a script in a TS under the user context?

Share this post


Link to post
Share on other sites

Ok, one more step closer to getting this straightened out.

 

If i add a run command line step (rundll32 printui...) to set the default printer in my TS and in the options set it to run as myself--which is the current logged in user--then it will work. However, it has issues if I use a service account, and I suspect that it is because the user is not logged in/the profile is not loaded to make the change.

 

I'm going to create a package with the rundll32 printui... command as a program, and set it to run under the current logged in user and see if that has any success.

Share this post


Link to post
Share on other sites

No dice there...creating a program to run under the user context is unusable in a TS...back to the drawing board...

Share this post


Link to post
Share on other sites

Well.. to be honest, you won't be able to do that for a user. Only for the user running the command, which doesn;t help you. Another thing you could do is to run it as the SYSTEM, which would cause every user to get it.

 

For an example, see: http://social.technet.microsoft.com/Forums/systemcenter/en-US/18f8f363-8d8d-4508-8a19-19ab739ae343/age-old-question-installing-printers-via-sccm

Share this post


Link to post
Share on other sites

I saw that post, but installing the printers isn't the issue (installing the printers has been the only part of this which is working as it should right now)...the problem comes when trying to set the default printer. If I can set the default printer after the install, the setting seems to stick for other users who logon afterwards...but as of right now, I can't find a method to set the default printer through a TS

Share this post


Link to post
Share on other sites

So far my testing and searches haven't turned anything up...I think I'm going to look at registry modification though. There are a couple settings which modifying doesn't require a restart, and may have the desired effect. but that could also have some very unpredictable results. :unsure:

Share this post


Link to post
Share on other sites

Well I have met with decent success over the weekend...my process thus far has turned the whole printer deployment and setting the default printer (which has been the primary focus) into a two part deployment, rather than just one. While I was "close" with some of my prior ideas, having everything run as a single deployment element was causing problems...so I split it up where I was having trouble: part one is the actual printer installs, and part two sets the default printer.

 

I modified my PS script so that in the first part, rather than actually set the default printer, I instead created a couple registry values that the second part of the deployment would use to set the default printer. Then, in the second part, I set a required deployment that also ran the first part of the install script (based on the presence of said registry value), and then taking the other registry value (the name of the default printer) proceeds to set the defaullt printer. This required deployment was set to run only while a user is logged in...so once their workstation is imaged and they logon for the first time, it will run and set the default printer from what has already been installed during OSD (if need be).

 

I still have more testing to do to verify that everything works under different circumstances, but so far, the fact that the default printer is getting set at this stage is still moderate success in my book. If anyone would like exact details on how I have this setup, I will hapily provide those.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...