Ok, I should give more of an explaination....
I have created a .cmd file (could just as well be a .bat file, i just felt like making a .cmd today). Inside of this file I have it running the command:
rundll32 printui.dll,PrintUIEntry /ga /c\\%1 /n\\%2
start /wait sc \\%1 stop spooler
start /wait sc \\%1 start spooler
I then have made a GPO to run the newly created cmd file. "\\domain\NETLOGON\Printer
Add.cmd" and as variables, I have %COMPUTERNAME% and servername\printershare. (Of note, the GPO is applied to a Computer OU, and the script is set in the Computer Settings of the GPO. The GPO is set to Loopback - Merge.)
This should, run the command and in place of the variables %1 and %2 insert the appropriate values so that we end up with something that equates to:
rundll32 printui.dll,PrintUIEntry /ga /c\\ComputerName /n\\Servername\PrinterShar
e
Which would, err, should add the printer globally (for any and all users on the local system). I added the spooler bit at the end so that it will force a restart of the spooler service so I dont have to log off and log back on to see the newly added printer.
In fact, it does work correctly. However, the problem I run into, is that the above script needs to be ran as local admin rights. So any domain admin account or local admin account will do. The problem is, that I want to use this for a lab in a school where the students and teachers will not have the appropriate access to run this. In my testing, I created a "test" student account and it when I logged on the first time, the printer was there, I deleted it and restarted and relogged in again as the same user, and the script is not being applied.
I believe the reason for this is the lack of credentials. So to my question.
Is there a way to get the above code to work for restricted users? I.e. something similar to a RunAs but for an entire policy? I would prefer to not have the username/password hard coded into the script, but maybe as a second variable, or have it call another file that would make it easy to check the credentials used by the script at all locations it gets called on.
I could use the vbs scripting method of objNetwork.AddWindowsPrint
erConnecti
on strUNCPrinter but I have had some difficulties lately and am looking for an alternative. And I dont want to make it so that one of the people who do have admin access have to go by and log in for the script to work everytime a student decides to delete their printer.
Any help is appreciated.
Start Free Trial