Afternoon all,

I thought i'd put up the set of login scripts I have created, to see what you all think

Heres the main login.kix
code:
SetConsole ("Hide") 

$max=10 ;the number of increments of the progress bar
pbar2(0,"Starting Logon Process")
Sleep 1
pbar2(1,"Defining Variables")
$public = "y:\"
$scriptpath = "y:\system32\scripts"
$clientname = "Customer"
$clientabbr = "CUS"
$logpath = "y:\system32\logpbar2(1,"Starting Logging")
;Redirect output to log
?RedirectOutput ("$logpath\@userid.log", 1)

;Logging some things.....
? "@userid, @fullname logging on to @wksta on @day, @month @mdayno, @year at @time"
? "System Processor is a @cpu, @mhz MHz"
$tmem = MemorySize(0) ;Calculate total system memory
$amem = MemorySize(1) ;Calculate available system memory
$spag = MemorySize(2) ;Calculate size of page file
? "$amem MB available of $tmem MB total system memory. Page file is $spag MB"
? "Logon Server = @lserver"
? "Logging to $logpath\@userid.log"
? "Priveledge Level = @priv"
? "Client OS = @producttype"
? "Public Drive = $public"
? "Path to scripts = $scriptpath"
? "Client Name = $clientname , $clientabbr"

pbar2(2,"Connecting Network Drives")
Call conndrvs.kix

pbar2(4,"Application Delivery")
Call appsdel.kix

pbar2(8,"Configuring Workstation")
Call appscfg.kix

;pbar2(9,"Updating Anti-Virus")
;? "Launching AntiVirus Script..."
;Shell "vplogon.bat"

pbar2(10,"Completing Login")
Call complete.kix

pbar2(11,"Logon Script Complete")
Sleep 1


; *********************************************************************************
Function pbar2($barpos, optional $Display)
If $barpos =0 ; Initiallize the form and it's Properties ****************
$root = CreateObject("KiXGUI.Desktop")
$form = $root.createform("form","")
$text = $form.addtextbox("text","",10,15,270,20,,1)
$form.TitleBar =0
$form.width =300
$form.height =80
; $form.center
$form.left =($form.parent.width-$form.width) / 2
$form.top =($form.parent.height-$form.height) / 2
$form.topmost =1
$form.layered =99
$Progressbar=$form.Addprogressbar("progress",10,45,270,20)
$Progressbar.ProgressBarStyle=2
$Progressbar.maxprogress=$max
$form.visible=1
EndIf
If $barpos>$max ; fade away and clean up *********************************
For $fade =99 to 0 step -1
$form.layered =$fade
Next
$form.visible=0
$root=0
Return
EndIf
If $barpos=>$Progressbar.currentprogress
$Progressbar.currentprogress=$barpos
EndIf
If $Display
$text.caption=$Display
EndIf
$form.visible=1
EndFunction

The kixgui stuff at the end is someone elses code that i threw in there untill i could figure out how to make my own funky gui things. i will be replacing that with some kixforms stuff once i have it all worked out [Smile]

i wont bother with conndrvs.kix because its just a bunch of use x: \\servername\sharename [Smile]

appsdel.kix
code:
? " "
? "Start of appsdel.kix"

$apps = "APP1","APP2","APP3" ;Define applications array

? "Begining Application Delivery Check Process"
$counter = 0
For Each $app In $apps
? " "
? "$app"

If InGroup("$clientabbr-$app")
? "User is in $clientabbr-$app Group"
$ReturnCode = ExistKey( "HKEY_LOCAL_MACHINE\software\kcs\version control\$app")
If $ReturnCode = 0
? "Application is already installed"
Else
? "Incrementing Counter by 1"
$counter = $counter + 1
? "Counter = $counter"
EndIf
Else
? "Not in $clientabbr-$app Group"
EndIf
Next

If $counter > 0
? " "
? "There is $counter apps to install, asing user if its ok"
$choice = MessageBox("Application Delevery has determined that $counter Applications are to be installed. Do you want to install them?", "Application Delivery", 36)
If $choice = 6
? "User selected Yes, Continuing......."
Else
? "User selected No, Aborting........"
Goto end
EndIf
Else
? "Counter is $counter Ending....."
Goto end
EndIf

? "Begining Application Delivery"
SetL "SU_DOMAIN = @domain"
SetL "SU_PASSWORD = installer"

For Each $app In $apps
? " "
? "$app"

If InGroup("$clientabbr-$app")
? "User is in $clientabbr-$app Group"
$ReturnCode = ExistKey( "HKEY_LOCAL_MACHINE\software\kcs\version control\$app")
If $ReturnCode = 0
? "Doing nothing, application is already installed"
Else
? "Now installing Application $app"
SetL "SU_COMMANDLINE = " + $scriptpath + "\appsdel\" + $app + ".exe"
;Shell "su.exe " + $clientabbr + "_installer -cb -l -e "
EndIf
Else
? "Doing nothing not in $clientabbr-$app Group"
EndIf

Next

:end
? " "
? "End of appsdel.kix"
Return

basicly what this script does, is checks if the user is in a group, and the existance of a registry key

if they are in the group, they should have the app, if the key exists the app is installed

if there in the group, and the key doesent exist, it installs the app, after first asking permission

the theory here is that a user can go to any workstation and login, and if they dont want all there apps installed, EG they just want to use standard apps like word or outlook, they can, without having all their apps installed. this is particularly usefull for shared pcs, such as one in the office here which has a scanner attached, people can just walk up and login.

appscfg.kix
code:
? " "
? "Start of appscfg.kix"

? "Set the default printer based on a registry check"

$DPrinter = ReadValue("HKEY_LOCAL_MACHINE\Software\KCS\Printer" , "Default")

If @ERROR=0
? "Default Printer Selection is $DPrinter"
If SetDefaultPrinter ("$DPrinter") = 0
? "Default Printer Sucessfully Set To $DPrinter"
Else
? "Failed to Set Default Printer to $DPrinter"
EndIf
Else
? "Failed to read default printer from registry"
EndIf

? "End of appscfg.kix"
Return

this script is for worstation configuration

the only thing in this script at the moment is to set the default printer based on a registry key on the workstation. normally default printer selection is stored in the profile. this script allows the default to be set based on the physical location of the machine. so the default is always set to the closest b&w laser

complete.kix
code:
? " "
? "Start of complete.kix"
if SetConsole ("show") = 0
? "Console Window Restored Successfully"
else
? "Console Window Restore Failed"
endif
? "End of complete.kix"
return

this code is intended for cleanup of things at the end of the login process, at the moment it just restores the command window to its normal state

phew!

a few of these scripts have room for additional things to be added, i work for a small consulting firm, so the scripts are designed so that customer specific customisations can be made, without things getting messy. a place for everything, and everything in its place.

the code above lost a few of the additional line spaces that were there to enhance readability, blame UBB