Jump to content

RunAs with Encrypted password and Add printer?


Recommended Posts

Hi Guys,

I am pretty sure I am doing something pretty dumb.. I am new to programming and new to scripting as well....

Scenario:

Laptop user's can't install printers b/c they don't have elevated priv...

I want to be able to write a script that runs the RunAS command and supplies the admin password in encrypted form. Meaning.. the admin password is encrypted within the script.. the user is verbally given a decrypt password for the _stringencrypt function... which in turn decrypts the admin password and launches the runas command and in turn launches the ADD Printer wizard for the end user.

Have I confused you enough Posted Image I got parts of it working from searching here on the forum etc.. but my command won't execute beyond the decryption....

Here is the code:

include <GuiConstantsEx.au3>
#include <String.au3>

Local $s_EncryptPassword, $s_EncryptText = "blahblahblah"

$s_EncryptPassword = InputBox("Security Check", "Enter your password.", "", "*")

$adminuser = "administrator"
$adminpass = _StringEncrypt(0, $s_EncryptText, $s_EncryptPassword, 1)
$var = "rundll32 printui.dll,PrintUIEntry /il"

RunAs($adminuser, @ComputerName, $adminpass, 0, @ComSpec & $var, @SW_MAXIMIZE)

any help would be greatly appreciated.... thx

Link to comment
Share on other sites

That didn't work for some reason but the following did: (cred. goes to the smart folks on this forum -- I found partial solution searching)

include <GuiConstantsEx.au3>
#include <String.au3>
;===========================================
;Utility for roaming users to be able to add printers w/o admin rights.... Nab 07/16/09
;===========================================
$s_EncryptText = "blah blah blah blah"

$s_EncryptPassword = InputBox("Security Check", "Enter your password.", "", "*")

$adminuser = "administrator"
$adminpass = _StringEncrypt(0, $s_EncryptText, $s_EncryptPassword, 1)
$admindomain = @ComputerName

Func _RunAsAdmin($cmd)
RunAs($adminuser, $admindomain, $adminpass, 0, $cmd)
EndFunc;==>_RunAsAdmin
$var = "rundll32 printui.dll,PrintUIEntry /il"
_RunAsAdmin($var)
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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