Jump to content
Sign in to follow this  

RunWait and RunAsWait problem

Recommended Posts


Hi all

I've just found AutoIt and have to say, am having a blast with it (crazy huh?).

I'm in the process of knocking up an application so our users can delete their current printers and add in their branch printers as local printers. Currently they are all set up on a print server in our data center but we're having issues with our more remote branches printing pdfs that take 15 minutes to spool as well as killing their bandwidth.

The script works exactly as it should when we run it as an admin user but all of our branch users are set up as only users, no admin rights. So I figured I'd just change from RunWait to RunAsWait and everything should be sweet.

I've copied one of the printer set up routines as an example.

RunWait ($printer) works perfectly well but RunAsWait ($user, $domain, $pass, 1, $printer) fails. I'm assuming it is due to the arguments not being passed through to the command line properly but I can't figure out how to get around it.

I'm hoping one of your readers has had the same issue and can point me in the right direction to resolve this.

Thanks for reading and hopefully, helping out :D



#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
;Define variables
$user = "user"
$domain = "domain"
$pass = "pass"
$wanit = "WANIT - Local"
$range = "IP_10.172.100.42"
$file = "h:\hp\hpcu115d.inf"
$driver = "HP Universal Printing PS"
RunAsWait ($user, $domain, $pass, 1, "cscript c:\windows\system32\prnport.vbs -a -r IP_10.172.100.42 -h -o raw -n 9100","","open",@sw_hide)
$printer = 'rundll32.exe printui.dll,PrintUIEntry /if /b "WANIT - Local" /r "IP_10.172.100.42" /f "h:\hp\hpcu115d.inf" /m "HP Universal Printing PS"'
RunWait ($printer)
RunAsWait ($user, $domain, $pass, 1, $printer)
MsgBox ( 0, "", "WANIT Installed")

Share this post

Link to post
Share on other sites

i would try running your printer command ('rundll32.exe printui.dll,PrintUIEntry /if /b "WANIT - Local" /r "IP_10.172.100.42" /f "h:hphpcu115d.inf" /m "HP Universal Printing PS"') from a dos prompt first with administrator rights to ensure that it works.

Although AutoIT is good this would be better implemented via a logon.vbs script applied through group policies. But thats just my opinion. logon scripts applied by the GPO overide the users rights.


Share this post

Link to post
Share on other sites

Thanks for the reply.

Yep that command runs fine in a dos box. The command runs fine when its run as a RunWait command as well, just the RunAsWait fails.

Odd problem that I can't see the answer to :D


Share this post

Link to post
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
Sign in to follow this