Sign in to follow this  
Followers 0
lulu

How do I install Windows printer drivers from script

10 posts in this topic

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.INF

This 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.INF

The 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?

Share this post


Link to post
Share on other sites



Are you using RunAsWait logon_flag 1?

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by 99ojo

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

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  
Followers 0