lulu Posted September 2, 2009 Posted September 2, 2009 How can I install a Windows printer driver from AutoIT script?I can run the following command from a DOS prompt to install a Windows printer driver:RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "Brother QL-1060N" /h "Intel" /v "Windows 2000 or XP" /f c:\working\brotherQL\QL106NV.INFThis works as long as I have Local Admin rights. I can also run this command from DOS using:runas /user:domain\admin RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "Brother QL-1060N" /h "Intel" /v "Windows 2000 or XP" /f c:\working\brotherQL\QL106NV.INFThe problem is that I need to run this command from a script on a PC where the user is not a Local Admin.The AutoIt RunAsWait command doesn’t work. I’ve tried putting the command string directly in the RunAsWait command. I’ve also tried putting the command in a .cmd file, and calling that from RunAsWait. In either case, RunAsWait returns 0. If I’m logged on as a Local Admin when I run the AutoIT script, it works fine.Is there some way to make RunAsWait work? Or is there someway to install the driver directly from a AutoIT?
LarryDalooza Posted September 2, 2009 Posted September 2, 2009 Are you using RunAsWait logon_flag 1? Lar. AutoIt has helped make me wealthy
ctyankeeinok Posted September 2, 2009 Posted September 2, 2009 Just a guess, but what if you compiled an AutoIT script to BrotherInstall.exe with the following code: Run(RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "Brother QL-1060N" /h "Intel" /v "Windows 2000 or XP" /f c:\working\brotherQL\QL106NV.INF)and then tried:RunAsWait("joeuser","mydomain","mypassword", 0, "BrotherInstall.exe")I am not certain of what login_flag will work best. The RunAs command Help has this little tidbit that may be your problem as well:"When running as an administrator, the Secondary Logon (RunAs) service must be enabled or this function will fail. This does not apply when running as the SYSTEM account."My idea may be a red herring....
lulu Posted September 3, 2009 Author Posted September 3, 2009 Are you using RunAsWait logon_flag 1?Lar.I've tried both 0 & 1. I'm running other RunAsWait commands just fine, once I changed the logon_flag from 2 to 0 that is. An example of a RunAsWait commnand that does work is:$AddPrinterString = StringFormat("cscript C:\\Windows\\System32\\prnmngr.vbs -a -p %s -m ""%s"" -r ip_%s", $printerName, $driverName, $ipAddr) RunAsWait("TDIScript", "z1", "Eeyore21!", 0, $AddPrinterString, @tempdir, @SW_HIDE)
99ojo Posted September 3, 2009 Posted September 3, 2009 (edited) Hi, try this RunAsWait with 4 $cmd = "RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m " & """" & "Brother QL-1060N" & """" & " /h " & """" & "Intel" & """" & " /v " & """" & "Windows 2000 or XP" & """" & " /f c:\working\brotherQL\QL106NV.INF" RunAsWait("joeuser","mydomain","mypassword", 4, $cmd) ;-)) Stefan Edited September 3, 2009 by 99ojo
lulu Posted September 3, 2009 Author Posted September 3, 2009 Just a guess, but what if you compiled an AutoIT script to BrotherInstall.exe with the following code: Run(RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "Brother QL-1060N" /h "Intel" /v "Windows 2000 or XP" /f c:\working\brotherQL\QL106NV.INF)and then tried:RunAsWait("joeuser","mydomain","mypassword", 0, "BrotherInstall.exe")I am not certain of what login_flag will work best. The RunAs command Help has this little tidbit that may be your problem as well:"When running as an administrator, the Secondary Logon (RunAs) service must be enabled or this function will fail. This does not apply when running as the SYSTEM account."My idea may be a red herring....This was a good idea, but it didn't work. Same thing, the admin permissions aren't getting through.
ctyankeeinok Posted September 3, 2009 Posted September 3, 2009 Have you tested the RunAs command (outside of AutoIT) on a machine, logged in as a local user without admin rights and the performing the RunAs? Your problem may be a rights issue on the machine, not AutoIT. The machine may not be configured to allow what you want to do (if I understand the comment from Help correctly).
lulu Posted September 3, 2009 Author Posted September 3, 2009 Have you tested the RunAs command (outside of AutoIT) on a machine, logged in as a local user without admin rights and the performing the RunAs? Your problem may be a rights issue on the machine, not AutoIT. The machine may not be configured to allow what you want to do (if I understand the comment from Help correctly).Thank you for your reply. I did confirm that the command will not run from a command prompt without using runas and local admin credentials. It does work using runas and the proper credentials.
lulu Posted September 3, 2009 Author Posted September 3, 2009 Hi, try this RunAsWait with 4 $cmd = "RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m " & """" & "Brother QL-1060N" & """" & " /h " & """" & "Intel" & """" & " /v " & """" & "Windows 2000 or XP" & """" & " /f c:\working\brotherQL\QL106NV.INF" RunAsWait("joeuser","mydomain","mypassword", 4, $cmd) ;-)) Stefan You ROCK! This worked. But it wasn't the 4. This also worked with 0. I was obviously doing something wrong formating the command. Thanks!!!
dot45 Posted September 3, 2009 Posted September 3, 2009 I'm late to the party, but check out the printer tool i have listed in my signature. You setup the printer (or printers) on one computer, backup the config to a file, then can blast it on to other machines. i have it setup with a gui, but you can just as easley set it up hard coded to a particular file and run it silently. Tools I've Created & Shared[/url][url="http://www.autoitscript.com/forum/index.php?showtopic=97177&st=0&p=698665&hl=printer&fromsearch=1&#entry698665"]Printer Migration Tool
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