Jbrad95706 Posted September 16, 2009 Posted September 16, 2009 Hello! I'm trying to allow my users to install local printers as a normal user. I use the runas command to open up the Add Remove Printers wizard, and it seems to be working properly until the second part of the wizard gets launched... I assume this is because it's a child process, and the runas permission as not being used for the child. Does anyone know of a workaround for this? I have seen solutions for adding a specific printer, but that's not what I'm looking for. I'm just tring to elevate permission for the user so they can add a new printer. Thanks in advance!!
5t0n3r Posted September 16, 2009 Posted September 16, 2009 Network shared printers or local printers? If you have some code you are already using, please post it as well.
Jbrad95706 Posted September 17, 2009 Author Posted September 17, 2009 Network shared printers or local printers? If you have some code you are already using, please post it as well. Local printers. $comp=@ComputerName RunAsSet ("Administrator",$comp,"TheLocalAdminPassword",0) ; Run the setup Run("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter") Without this the option to install local printers is grey, but with it - they can select local printer. The problem is when the wizard starts another process. The system prompts for a username and password, and no matter what I enter, the program errors out. (Access denied)
5t0n3r Posted September 17, 2009 Posted September 17, 2009 Here's a modified version of the script. You'll need to make sure you have the latest version of AutoIt for it to work and compile properly. $user="Administrator" $pass="Password" $comp=@ComputerName RunAs($user,$comp,$pass,0,"rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter")
Jbrad95706 Posted September 18, 2009 Author Posted September 18, 2009 (edited) Here's a modified version of the script. You'll need to make sure you have the latest version of AutoIt for it to work and compile properly. $user="Administrator" $pass="Password" $comp=@ComputerName RunAs($user,$comp,$pass,0,"rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter") I upgraded to 3.3 - and used this exact code in my script. (With the correct passowrd) Now nothing happens... I get an hourglass for a second, and then nothing. Edit: The rundll32 command works on the command line, so I know that's correct. Im at a loss on this... Edited September 18, 2009 by Jbrad95706
5t0n3r Posted September 18, 2009 Posted September 18, 2009 Try this. A little simplier, but works. $comp=@ComputerName RunAs("Administrator",$comp,"TheLocalAdminPassword",0,"rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter")
Jbrad95706 Posted September 18, 2009 Author Posted September 18, 2009 (edited) Try this. A little simplier, but works. $comp=@ComputerName RunAs("Administrator",$comp,"TheLocalAdminPassword",0,"rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter") I was just coming back to let you know that I got it working. I uninstalled AutoIT and reinstalled, then recompiled it, and it worked... It still prompts for a username and password about half way through, but I just click that window out and continue, and it seems to work. Unrelated question... is there any way to change the default icon? I'm trying to slap a printer looking icon on it, but not having much luck. Either way - thank you very much! Edited for Typo's! Edited September 18, 2009 by Jbrad95706
Jbrad95706 Posted September 18, 2009 Author Posted September 18, 2009 (edited) Hmmm... it's working on my PC but when I send it to a co-worker it does nothing when they click on it. Howerglass for a second, and nothing.... I checked to make sure that the local admin password was the same on both systems and it is... Edit: ...but it worked on two other PC's Looks like I'm in good shape! Thanks for your help! Edited September 18, 2009 by Jbrad95706
5t0n3r Posted September 18, 2009 Posted September 18, 2009 I was just coming back to let you know that I got it working. I uninstalled AutoIT and reinstalled, then recompiled it, and it worked... It still prompts for a username and password about half way through, but I just click that window out and continue, and it seems to work. Unrelated question... is there any way to change the default icon? I'm trying to slap a printer looking icon on it, but not having much luck. Either way - thank you very much! Edited for Typo's! Best thing to do is download the full version of SciTe editor from the download page and in it there's a (Ctrl + F7) Build option that give you the ability to specify an icon. If you want to modify the tray icon and it's text, here's a bit of code for that. Opt("TrayMenuMode",1) TraySetIcon("path to file.ico") TraySetToolTip("Tool Tip Popup Text") TraySetState()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now