gkalus Posted December 9, 2012 Share Posted December 9, 2012 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 9, 2012 Share Posted December 9, 2012 Where in this script does it freeze? And is it freezing Windows, or the script is freezing? 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 Link to comment Share on other sites More sharing options...
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