
gkalus
Members-
Posts
8 -
Joined
-
Last visited
gkalus's Achievements

Seeker (1/7)
0
Reputation
-
Add Network Printer using command line
gkalus replied to gkalus's topic in AutoIt General Help and Support
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 -
Compiled Script causes Windows to Freeze up
gkalus posted a topic in AutoIt General Help and Support
I got the script below running but when it is compiled and I run it from the USB or locally, it freezes windows up. I need to run this script from a USB drive and have written it on the USB. It does three things. Creates a printer port Loads the print drivers Adds the printer The script pulls all the drivers from the USB drive. The beginning of the script is for formatting the IP address and adding the correct number of digits in the last two octets of the IP address to get the proper naming of the printer. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=C:\Program Files\AutoIt3\Icons\printer_laserjet.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $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 & '\Drivers\hppcp610.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 Local $InstPrtDrv = ' /c C:\Windows\System32\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 for the help, GK -
Compiled Script causes Windows to Freeze up
gkalus posted a topic in AutoIt General Help and Support
I got the script below running but when it is compiled and I run it from the USB or locally, it freezes windows up. I need to run this script from a USB drive and have written it on the USB. It does three things. Creates a printer port Loads the print drivers Adds the printer The script pulls all the drivers from the USB drive. The beginning of the script is for formatting the IP address and adding the correct number of digits in the last two octets of the IP address to get the proper naming of the printer. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=C:\Program Files\AutoIt3\Icons\printer_laserjet.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $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 & '\Drivers\hppcp610.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 Local $InstPrtDrv = ' /c C:\Windows\System32\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 for the help, Gary -
Add Network Printer using command line
gkalus replied to gkalus's topic in AutoIt General Help and Support
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. Local $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 -
Add Network Printer using command line
gkalus replied to gkalus's topic in AutoIt General Help and Support
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 -
Add Network Printer using command line
gkalus replied to gkalus's topic in AutoIt General Help and Support
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 -
Add Network Printer using command line
gkalus replied to gkalus's topic in AutoIt General Help and Support
Nope it didn't work there is no spaces in the path. The actual @WorkingDir is: D:Create_PrinterHPCP2025 Any other suggestions? Thanks, Gk -
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