Originally Posted By: cjutting
Thanks for your input Mart. Couple of questions so I understand what your telling me.

Start with the printers.

What you are suggesting is:

 Code:
if ingroup ("BO-")
  $rc = AddPrinterConnection ("\\server\Business Office")
endif

....

Exactly. This will prevent any return codes from being displayed on the screen.

 Originally Posted By: cjutting

....
Also interested in seeing how you check against how the user has a current drive mapping. My only thought was in the logon.bat put in a net use * /d /y to remove the drives and then remap them all.

I need to do more reading on how to use an ini file along with this.


Below is a piece of my script that does the drive mapping and checks. The example below handles one drive that everyone in our company should get so that's why it checks on membership of domain users. For other drives it is just a matter of copy paste and changing a few settings so it uses the correct letter, share and label.
There are lots of comments in it that should make it clear what it is doing. The script below requires some UDF's.
EnumNetworkDrives() - Returns the current network drive mapping information
Label() - Read & Write Drive Label
RemoveNullRows() - remove rows from an array that are blank/null

 Code:
Break on

;Get all currently mapped network drives.
$networkdrives = EnumNetworkDrives()
;Create an array that will hold the letters of all mapped drives.
Dim $mapped[26]

If InGroup("Domain Users")
	;Set drive letter.
	$drive = "O:"
	;Set path.
	$path = "\\server\share"
	;Check to see if the drive exists.
	If Exist($drive + "\")
		;Drive exists.
		;Check to see if drive settings are correct.
		For $i = 0 to UBound($networkdrives)
			;Split the current network drives so you get two elements.
			;One element holds the drive letter the other holds the path.
			$networkdrive = Split($networkdrives[$i], ",")
			$networkdriveletter = $networkdrive[0]
			$networkdrivepath = $networkdrive[1]
			;Check to see if the drive to map matches an existing drive.
			If $networkdriveletter = $drive
				;Check to see if the path to the drive is correct and if the drive has not
				;been mapped by this script already.
				If $networkdrivepath = $path And AScan($mapped, $drive) = -1
					;Path to the drive is correct.
					;Set the display name of the drive.
					Label($drive, "User friendly name goes here")
					;Set a variable to indicate that this drive has been mapped succesfully.
					$mapped[$mappedindex] = $drive
					;Increase the index by 1.
					$mappedindex = $mappedindex + 1
				Else
					;Path to the current drive is not correct.
					;Delete the drive that uses the drive letter to be mapped.
					Use $drive /delete /persistent
					;Map correct drive.
					Use $drive $path
					;Set the display name of the drive.
					Label($drive, "User friendly name goes here")
					;Set a variable to indicate that this drive has been mapped succesfully.
					$mapped[$mappedindex] = $drive
					;Increase the index by 1.
					$mappedindex = $mappedindex + 1
				EndIf
			EndIf
		Next
	Else
		;Drive does not exist.
		;Map the correct drive.
		Use $drive $path
		;Set the display name of the drive.
		Label($drive, "User friendly name goes here")
		;Set a variable to indicate that this drive has been mapped successful.
		$mapped[$mappedindex] = $drive
		;Increase the index by 1.
		$mappedindex = $mappedindex + 1
	EndIf
EndIf

;Remove empty elements from the array that holds all mapped drives.
$mapped=removenullrows($mapped)
;Check all old network drives and compare them with the drives that are mapped by this script.
For $i = 0 to UBound($networkdrives)
	;Split each drive on the comma.
	$networkdrive = Split($networkdrives[$i],",")
	$networkdriveletter = $networkdrive[0]
	;Check to see if the old rive is listed in the array of newly mapped drives.
	If AScan($mapped, $networkdriveletter) = -1
		;Old drive is not listed so delete it.
		Use $networkdriveletter /Del /Persistent
	EndIf
Next


 Originally Posted By: cjutting

Also maybe I'm missing it, but how is kix keeping track of errors that are in turn written to the log files and then emailed to IT.

Every (sub) script of my logon script uses error tracking if needed. If there is an error it reads the current number of errors from the ini file, increases it by one and writes the new value back to the ini file. The text log is only used for admin purposes. A line is written to the text log any time something goes wrong. The last script I run checks for errors by reading the number of errors from the ini file and sends an e-mail if there are more than 0 errors. It also attaches the text log file to the e-mail so we can see what went wrong and fix it.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.