Sign in to follow this  
Followers 0
gkalus

Compiled Script causes Windows to Freeze up

3 posts in this topic

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

Share this post


Link to post
Share on other sites



Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0