Jump to content

Recommended Posts

Posted

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!! :D

Posted

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)

Posted

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")
Posted (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. :D

Edit: The rundll32 command works on the command line, so I know that's correct.

Im at a loss on this... :D

Edited by Jbrad95706
Posted

Try this. A little simplier, but works.

$comp=@ComputerName
RunAs("Administrator",$comp,"TheLocalAdminPassword",0,"rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter")
Posted (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. :D I uninstalled AutoIT and reinstalled, then recompiled it, and it worked... :D

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. :D

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 by Jbrad95706
Posted (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... :D

Edit: ...but it worked on two other PC's :D Looks like I'm in good shape!

Thanks for your help!

Edited by Jbrad95706
Posted

I was just coming back to let you know that I got it working. :D I uninstalled AutoIT and reinstalled, then recompiled it, and it worked... :D

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. :D

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()

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...