Domain Logon Scripting
July 12, 2004
I prefer using kixstart for writing domain logon scripts instead of just plain bat files. Here are a couple examples.
Example kixstart script:; ; Clear Screen ; CLS ? "Print some kind of message to the user" ; ; Redirect any output to the log file. ; IF RedirectOutput("\server@WKSTA.log",1) = 0 ; ELSE ? "Error running logon script!" SLEEP 100 QUIT ENDIF ; stop user for killing script BREAK off IF (@inwin = 1) $NT_mode="yes" ELSE $NT_mode="no" ENDIF $os="" $os_dos=@dos SELECT CASE ($NT_mode = "yes") AND ($os_dos = "5.1") ; - Windows XP - $os="XP" CASE ($NT_mode = "yes") AND ($os_dos = "5.0") ; - Windows 2000 - $os="W2K" CASE ($NT_mode = "yes") ; - Windows NT - $os="NT4" CASE ($NT_mode <> "yes") AND ($os_dos = "4.90") ; - Windows ME - $os="ME" CASE ($NT_mode <> "yes") AND ($os_dos = "4.10") ; - Windows 98 - $os="W98" CASE ($NT_mode <> "yes") AND ($os_dos = "4.0") ; - Windows 95 - $os="W95" CASE 1 $os="???" ; - undetermined - ENDSELECT ; ; Set time ; SETTIME "\server" ; ; Map Some Drives ; USE O: "\server@USERID$" USE M: "\serverMData" IF InGroup("DOMAINgroup") ? "In group!" ; do some other stuff for people in group NDIF ; ; Add printers. ; If ADDPRINTERCONNECTION ("\serverHPLaserJet") = 0 ? "Added printer connection." Endif ; ; Print out some local computer information. ; ? "Logging on user @FULLNAME (@USERID) at @DATE @TIME" ? "Computer Name: @HOSTNAME (@WKSTA)" ? "Operating System: @PRODUCTTYPE (@BUILD,@CSD)" ? "CPU Type: @CPU" $memsize = MemorySize() ? "RAM Size: $memsize" $diskspace = GetDiskSpace("C:") ? "Drive C Size (kb): $diskspace" QUIT
Test if a computer is a server:
$isServer = 0 select case INSTR($os_producttype, "Server") > 0 $isServer = 1 case INSTR($os_producttype, "Domain") > 0 $isServer = 1 endselect If $isServer = 1 Exit Endif