Hello everybody. I hope some one can help me to figure out why my script hangs on the part of installing printers. The script works but sometimes some PC's execute the script really slow. Other times PC's execute the script real fast. I don't understand why it doesn't execute fast alll the time. Is there something in my script that i can do to speed things up.
I appreciate any help



 Code:
 

color w+/m                                               ;change background color to yellow
cls                                                     ;Clears the screen

?"Here is some information about your session:"
?
?"Current Computer Name:        @wksta."
?"The Server you logged into:   @lserver."
?"Your IP Address is:           @ipaddress0."
?
?"Please wait while your login script connects all network resources..."



;;;;;;;;;;;;;;;;;;
; Script Options ;
;;;;;;;;;;;;;;;;;;
Debug on
If Not @LOGONMODE
	Break On
Else
	Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
	$RC = SetOption("WrapAtEOL", "On")
EndIf

;;;;;;;;;;;;;;;;;;;;;
; Declare variables ;
;;;;;;;;;;;;;;;;;;;;;

Dim $Printers, $Printer
Dim $Drives, $Drive

; Server Name Variables
Dim $fileserver
Dim $newtechsrv


;;;;;;;;;;;;;;;;;;;;;;;;
; Initialize variables ;
;;;;;;;;;;;;;;;;;;;;;;;;

$Drives = Split('f:|g:|h:|i:|j:|k:|l:|m:|n:|o:|p:|q:|r:|s:|t:|u:|v:|w:|x:|y:|z:','|')


$Printers = '\\server\FIN',
'\\server\MEM',
'\\server\PS3',
'\\server\LJCPS',
'\\server\NPS',
'\\server\TN', 
'\\server\TN2',
'\\server\PCL6', 
'\\server\S',
'\\server\L6',
'\\server\24',
'\\server\7310' 

; Server Name Variables
$fileserver = 'server2'
$newtechsrv = 'server3'

;;;;;;;;
; Code ;
;;;;;;;;

; Disconnecting all network drives...
For Each $Drive in $Drives
	Use $Drive /del
Next

; Drive Mappings
Use k: '\\' + $fileserver + '\Pu'
Use l: '\\' + $fileserver + '\share'

If InGroup('fso_OfSvc')
	Use j: '\\' + $fileserver + '\OfSvc'
EndIf

If InGroup('fso_mem')
	Use p: '\\' + $fileserver + '\Mem'
EndIf

If InGroup('fso_member')
	Use i: '\\' + $fileserver + '\iMIS_LIVE'
EndIf

If InGroup('fso_fin')
	Use s: '\\AM01\SAGE'
	Use f: '\\' + $fileserver + '\Fin'
EndIf

If InGroup('fso_hr')
	Use x: '\\' + $fileserver + '\HR'
EndIf

If InGroup('fso_med')
	Use p: '\\' + $fileserver + '\MED'
EndIf

If InGroup('fso_mark')
	Use p: '\\' + $fileserver + '\Com'
EndIf

;IF INGROUP('fso_mark_cr')
;  use q: '\\' + $fileserver + '\Cr'
;ENDIF

If InGroup('fso_qa')
	Use q: '\\' + $fileserver + '\QA'
EndIf

If InGroup('fso_cha')
	Use p: '\\' + $fileserver + '\Cha'
EndIf

If InGroup('fso_pr')
	Use h: '\\' + $fileserver + '\Pr'
EndIf

If InGroup('fso_mark_space')
	Use o: '\\' + $fileserver + '\Space'
EndIf

If InGroup('fso_KT')
	Use t: '\\' + $fileserver + '\Knowledge'
EndIf

If InGroup('fso_ch')
	Use m: '\\' + $fileserver + '\Ch'
EndIf

If InGroup('fso_export')
	Use g: '\\' + $fileserver + '\Export'
EndIf

If InGroup('fso_r')
	Use r: '\\' + $fileserver + '\R'
EndIf

If InGroup('fso_tech')
	Use z: '\\' + $newtechsrv + '\Tech'
EndIf

If InGroup('fso_dwa')
	Use w: '\\' + $fileserver + '\D'
EndIf

If InGroup('fso_Rec')
	Use x: '\\' + $fileserver + '\Rec'
EndIf

If InGroup('fso_Re')
	Use x: '\\' + $fileserver + '\Performance\%USERNAME%'
EndIf

If InGroup('Non-Exempt Employees')
	Copy '\\DC01\NETLOGON\PunchINPunchOUT.url' '%USERPROFILE%\Start Menu\Programs\Startup\PunchINPunchOUT.url'
EndIf

If Exist('%USERPROFILE%\desktop\DatabaseCalender.lnk')
	Del '%USERPROFILE%\desktop\DatabaseCalender.lnk'
EndIf

If Not @wksta = "SQL" Or Not @wksta = "MAIL"
	If @wksta = "RIX01" Or @wksta = "RIX02"
		If @userid = "Administrator"
			$RC = WriteValue("HKEY_Current_user\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "StartMenuAdminTools", "NO", "REG_SZ")
		EndIf
	EndIf
	;Installs printers for everybody.
	If @wksta <> 'server'
		; Installing Printers...
		If InGroup("fso_tech")
			 ?"Mailroom printer install"
			If PriMapState('\\server\XWC120PS') = ''
				$RC = AddPrinterConnection('\\server\XWC120PS')
			EndIf
		EndIf
		For Each $Printer in $Printers
				If PriMapState($Printer) = ''
					$RC = AddPrinterConnection($Printer)
				EndIf
		Next
	EndIf
	;Changes setting for tabs in IE7 
	$RC = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TabbedBrowsing", "ShortcutBehavior", "0", "REG_DWORD")
	
	;Turns Internet Explorer start page to blank, enables recover deleted items in Outlook, and sets IM and AutoArchive Preferences
	$RC = WriteValue("hkey_Current_user\Software\Microsoft\Internet Explorer\Main", "Window Title", "Provided by", "REG_SZ")
	$RC = WriteValue("hkey_Current_user\Software\Microsoft\Office\11.0\Outlook\IM", "Enabled", "0", "REG_DWORD")
	$RC = WriteValue("hkey_Current_user\Software\Microsoft\Office\11.0\Outlook\Preferences", "DoAging", "0", "REG_DWORD")
EndIf

;;;;;;;;;;;;;;;;;;;;;;;;
; Personal UDF Section ;
;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;
; UDF Section ;
;;;;;;;;;;;;;;;

; Do not forget to add the PriMapState UDF

function PriMapState($_Pri)
if @inwin=1
 if len(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices",$_Pri))
  if split(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),",")[0]=$_Pri
   $PriMapState=2
  else
   $PriMapState=1
  endif
 endif
else
 dim $_Root,$_C,$_C2 $_Root="HKLM\System\CurrentControlSet\control\Print\Printers"
 for $_C=0 to 259
  $_C2=enumkey($_Root,$_C)
  If instr(READVALUE($_Root+"\"+$_C2,"Port"),$_Pri)
   If instr(READPROFILESTRING("%windir%\win.ini","windows","device"),$_Pri)
    $PriMapState = 2
   Else
    $PriMapState = 1
   Endif
  Endif
  if $_C2=259 $_C=$_C2 endif
 next
endif
endfunction



Edited by amtagoran (2010-04-28 04:37 PM)