gkalus Posted December 5, 2012 Posted December 5, 2012 Okay, I'm new here. I have play with this script for a couple of days, off and on. I need a new set of eyes on it. There is no problem with adding the printer port but the printer is another thing - it just doesn't work. I had it working and changed some of the variables and now there is somthing wacky with the second RunWait command. The print drivers are in a folder called Drivers that is in the same folder the script is in. Here is the code: Local $IPAddress = "172.20.20.20" Local $IPName = "012012" Local $octet3 = 20 Local $octet4 = 20 Local $PortName = '"'& "IP_" & $IPAddress & '"' Local $PrinterName = '"'& "HHSPR" &$IPName&'"' ; Check Name "PR" or "RH" Local $PrtDriver = '"HP Color LaserJet CP2020 Series PCL 6"' ;Name of Print Driver goes here Local $PrtComment = '"HP Color LaserJet CP2025"' ; Name of printer goes here for comment field Local $DriveDir = @WorkingDir & "\HP\CP2025\Drivers\autorun.inf" ; Check and change directory and .INF file - Lead with a "\" ;Adding Printing Port Local $InstPrtPort = " /c cscript c:\Windows\System32\prnport.vbs -a -r IP_"&$IPAddress&" -h "&$IPAddress&" -o raw -n 9100 -2e" RunWait(@ComSpec & $InstPrtPort) ;Creatation command for new port ;Installing Print Drivers Local $InstPrtDrv = " /c c:\windows\system32\rundll32 printui.dll,PrintUIEntry /if /b "&$PrinterName&" /f "&$DriveDir&" /r "&$PortName&" /m "&$PrtDriver&"" RunWait(@ComSpec & $InstPrtDrv) Thanks for the help. GK
Mat Posted December 5, 2012 Posted December 5, 2012 I bet there is a space in @WorkingDir! See if this works for you: Local $InstPrtDrv = " /c C:\Windows\System32\rundll32 printui.dll,PrintUIEntry /if /b "&$PrinterName&" /f """&$DriveDir&""" /r "&$PortName&" /m "&$PrtDriver&"" AutoIt Project Listing
gkalus Posted December 5, 2012 Author Posted December 5, 2012 Nope it didn't work there is no spaces in the path. The actual @WorkingDir is: D:Create_PrinterHPCP2025 Any other suggestions? Thanks, Gk
careca Posted December 5, 2012 Posted December 5, 2012 I would use ShellExecuteWait, because this one supports switches/parameters. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
BrewManNH Posted December 5, 2012 Posted December 5, 2012 Nope it didn't work there is no spaces in the path. The actual @WorkingDir is: D:Create_PrinterHPCP2025If your @WorkingDir is D:Create_PrinterHPCP2025 then your $DriveDir variable will contain D:Create_PrinterHPCP2025HPCP2025Driversautorun.inf, is that what you're looking for? Or do you want to use @ScriptDir instead? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
gkalus Posted December 6, 2012 Author Posted December 6, 2012 (edited) Yes, the correct path to the drivers and .inf file is: D:Create_PrinterHPCP2025Driversautorun.inf I am using the variable for the @WorkingDir and then I will be able to point to different driver folders for different printers in this case it is a HP-Color Printer 2025 that I am trying to load. Between the @WorkingDir and the $DriveDir they build the variable path to the different .inf files. I have tried with MsgBox to diplay the path without running the script and it looks correct. Thanks, GK Edited December 6, 2012 by gkalus
BrewManNH Posted December 6, 2012 Posted December 6, 2012 BTW, autorun.inf isn't usually a driver inf file, it's usually the file used when the drivers are on a CD. Also, make sure that you're pointing to the folder that holds the OEMxxxx.inf file, where the actual driver files are. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
gkalus Posted December 6, 2012 Author Posted December 6, 2012 This is a copy of the CD and the is not OEMxxxxx.inf file anywhere. When I add the printer manually it work off this directory and files it works great. there are three .inf files: autorun.inf hppaew10.inf hppcp610.inf I have tried the script with each of these files and the script still fails. Still looking for the correction that will get the script running. Thanks, GK
gkalus Posted December 9, 2012 Author Posted December 9, 2012 Okay, I think I have it. The code below works BUT when it is compiled it freezes windows. Keep in mind that I setup printers on our network based on the IP address. The goal is to have an executable for each model of printer we have. I am using variable to change the Printer Port, Printer Name, Print Driver, and location of the Printer drivers. I would appreciate any help with this to figure out when this script is complied it Freezes Windows. expandcollapse popupLocal $IPAddress = "172.20." Local $IPAddress = InputBox("Create a Standard TCP/IP Printer Port", "Enter IP Address for Standard TCP/IP Printer Port (CR+LF) test", "172.20.", "", 0) ;Creating the third octet Select Case StringMid($IPAddress, 9, 1) = "." Local $octet3 = "00" & StringMid($IPAddress, 8, 1) Case StringMid($IPAddress, 10, 1) = "." Local $octet3 = "0" & StringMid($IPAddress, 8, 2) Case StringMid($IPAddress, 8, 3) > 99 And StringMid($IPAddress, 8, 3) < 255 Local $octet3 = StringMid($IPAddress, 8, 3) EndSelect ;Creating the fourth octet Select Case StringIsDigit(StringRight($IPAddress, 3)) = 1 Local $octet4 = StringRight($IPAddress, 3) Case StringRight($IPAddress, 2) > 9 And StringRight($IPAddress, 2) < 100 Local $octet4 = "0" & StringRight($IPAddress, 2) Case Else Local $octet4 = "00" & StringRight($IPAddress, 1) EndSelect Local $IPName = $octet3 & $octet4 Local $PortName = '"'& "IP_" & $IPAddress & '"' ; ************************ Configuring names (Check these names) ************************ Local $PrinterName = '"'& "HHSPR" &$IPName&'"' ; Check Name "PR" or "RH" Local $PrtDriver = '"HP Color LaserJet CP2020 Series PCL 6"' ;Name of Print Driver goes here Local $DriveDir = '"' & @WorkingDir & 'HPCP2025Drivershppcp610.inf"' ; Check and change directory and .INF file - Lead with a "" ; ************************ End of priter name changes ************************ ;Adding Printing Port Local $InstPrtPort = " /c cscript C:\Windows\System32\prnport.vbs -a -r IP_"&$IPAddress&" -h "&$IPAddress&" -o raw -n 9100 -2e" RunWait(@ComSpec & $InstPrtPort) ;Creatation command for new port ;Installing Print Drivers Local $InstPrtDrv = ' /c rundll32 printui.dll,PrintUIEntry /ia /m '&$PrtDriver&' /h "Intel" /v "Windows 2000 or XP" /f '&$DriveDir&'' RunWait(@ComSpec & $InstPrtDrv) ;Add Printer Local $InstPrinter = " /C cscript C:\Windows\System32\prnmngr.vbs -a -p "&$PrinterName&" -m "&$PrtDriver&" -r "&$PortName&"" RunWait(@ComSpec & $InstPrinter) ; Message after printer has been added MsgBox(4096, "New Printer", "Printer: " &$PrinterName& " has been added.") Thanks, GK
gkalus Posted December 10, 2012 Author Posted December 10, 2012 Got the answer. It seems to freeze up because of anti-virus software. With AV disabled it works like it is supposed to. Thanks, GK
alex16 Posted February 1, 2013 Posted February 1, 2013 Hi Guys, any thoughts to how the script would install drivers for Win vista/win7 and win 8? cheers.
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