#68829 - 2002-08-02 05:05 AM
Login Scripts
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
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
i wont bother with conndrvs.kix because its just a bunch of use x: \\servername\sharename
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
|
Top
|
|
|
|
#68832 - 2002-08-04 11:24 AM
Re: Login Scripts
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
The apps are repackaged as single executables that run without any prompts. They just pop up, and display a progress bar as they install. These application packages include the registry key for checking
su is used to install the packages with admin rights as bleonard said.
the only place i could see where y: is used rather than the variable is at the start of login.kix where all the variables are defined
the reason why the smaller script files such as complete.kix exist, is that we setup sites for a number of different clients, and this way makes it cleaner if we have to add customisations to those parts of the login script. it seems a bit off in the base configuration, but where these customisations are used, its much nicer.
|
Top
|
|
|
|
#68833 - 2002-09-02 06:28 AM
Re: Login Scripts
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
Here's my new login.kix
code:
SetConsole ("Hide")
;Setup the GUI $Form = CreateObject("Kixtart.Form") $form.text = "Logon In Progress....." $Form.Size = 300,400 $form.backcolor = 255,255,255 $Form.Center
$pbar = $Form.progressbar $pbar.width = 240 $pbar.height = 10 $pbar.min = 0 $pbar.max = 20 $pbar.center $pbar.top = 350 $pbar.borderstyle = 0
$logo = $form.image(login.bmp) $logo.center $logo.top = 15 $logo.borderstyle = 0
$text = $form.textbox $text.locked = 1 $text.width = 240 $text.height = 20 $text.center $text.top = 320 $text.value = HELLO!
$form.show
$pbar.value = 0 $text.value = "Starting Login Progess" Sleep 1
$pbar.value = 1 $text.value = "Defining Variables"
$public = "y:\" $scriptpath = "y:\system32\scripts" $clientname = "Customer" $clientabbr = "CUS" $logpath = "y:\system32\log"
$pbar.value = 2 $text.value = "Starting Logging" ? 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"
$pbar.value = 4 $text.value = "Connecting Network Drives" Call conndrvs.kix
$pbar.value = 8 $text.value = "Application Delivery" Call appsdel.kix
$pbar.value = 16 $text.value = "Configuring Workstation" Call appscfg.kix
$pbar.value = 18 $text.value = "Updating Anti-Virus" ? "Launching AntiVirus Script..." Shell "vplogon.bat"
$pbar.value = 19 $text.value = "Completing Login" Call complete.kix
$pbar.value = 20 $text.value = "Logon Script Complete" Sleep 1
basicly the same as before, just with a new kixforms gui
|
Top
|
|
|
|
#68834 - 2002-10-07 11:21 AM
Re: Login Scripts
|
BrianK
Getting the hang of it
Registered: 2002-10-02
Posts: 90
Loc: Amsterdam, The Netherlands
|
Hey Redback,
i'm trying to implement your part of the script, that should generate a graphical progress of the logon. However... Me being a novice at Kixtart and all... can't figure out, how to make it work.
Below is the how I tried to test it. But the result is, that the (dos)box opens a fraction of a second and then closing it again, not doing anything. Could you please shed some light on this for me?
By the way... is there loss of perfomance, when using the Kix GUI? I ask this question because we have a few dial in users also.
Thanx in advance.
Brian
code:
SetConsole ("maximize") ;Setup the GUI $Form = CreateObject("Kixtart.Form") $form.text = "Logon In Progress....." $Form.Size = 300,400 $form.backcolor = 255,255,255 $Form.Center $pbar = $Form.progressbar $pbar.width = 240 $pbar.height = 10 $pbar.min = 0 $pbar.max = 20 $pbar.center $pbar.top = 350 $pbar.borderstyle = 0 $logo = $form.image(login.bmp) $logo.center $logo.top = 15 $logo.borderstyle = 0 $text = $form.textbox $text.locked = 1 $text.width = 240 $text.height = 20 $text.center $text.top = 320 $text.value = HELLO! $form.show
$pbar.value = 0 $text.value = "Starting Logon Progess" Sleep 1 $pbar.value = 1 $text.value = "Copying files to Local" Select CASE @INWIN = ("1") ;Windows NT If exist (@LDRIVE + "\lmhosts.") copy @LDRIVE + "\lmhosts." %systemroot%\system32\drivers\etc EndIf If exist (@LDRIVE + "\hosts.") copy @LDRIVE + "\hosts." %systemroot%\system32\drivers\etc EndIf If exist (@LDRIVE + "\services.") copy @LDRIVE + "\services." %systemroot%\system32\drivers\etc EndIf If exist ("%systemroot%\system32\nbtstat.exe") run "%systemroot%\system32\nbtstat -R" "" ? EndIf CASE @INWIN = ("2") ;Windows 9x If exist (%LSERVER%\netlogon\lmhosts.) copy %LSERVER%\netlogon\lmhosts. %windir% EndIf If exist (%LSERVER%\netlogon\hosts.) copy %LSERVER%\netlogon\hosts. %windir% EndIf If exist (%LSERVER%\netlogon\services.) copy %LSERVER%\netlogon\services. %windir% EndIf If exist ("%windir%\nbtstat.exe") run "%windir%\nbtstat -R" "" ? EndIf EndSelect $pbar.value = 2 $text.value = "Mapping the Drives" use n: /d use n: "\\nlwl10\stahl" use o: /d use o: "\\%USERSERVER%\@userid$" use p: /d use p: \\%USERSERVER%\data use q: /d use q: "\\%USERSERVER%\%DEPARTMENT%dat" use s: /d use s: \\%USERSERVER%\mtapps use t: /d use t: \\%USERSERVER%\siteapps
$pbar.value = 3 $text.value = "Unassociating .vbs/.js and .wsh extensions " $res = DELTREE ("HKEY_CLASSES_ROOT\JSFile\Shell") $res = DELTREE ("HKEY_CLASSES_ROOT\VBSFile\Shell") $res = DELTREE ("HKEY_CLASSES_ROOT\WSHFile\Shell") $res = DELTREE ("HKEY_CLASSES_ROOT\Microsoft Internet Mail Message\Shell") $res = DELTREE ("HKEY_CLASSES_ROOT\Microsoft Internet News Message\Shell")
$pbar.value = 4 $text.value = "Logon Script Complete" Sleep 1
_________________________
Rodney Dangerfield:
“My mother didn't breast-feed me. She said she liked me as a friend.”
|
Top
|
|
|
|
#68839 - 2006-05-11 05:46 AM
Re: Login Scripts
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
omg thread revival!
hi everyone!
|
Top
|
|
|
|
#202992 - 2011-08-29 06:46 AM
Re: Login Scripts
[Re: Redback]
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
5 years?
I think I'm due for a bump
|
Top
|
|
|
|
#202996 - 2011-08-30 10:30 PM
Re: Login Scripts
[Re: NTDOC]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Technically 9 years, if not, then he's probably working in a bakery by now
|
Top
|
|
|
|
#203042 - 2011-09-07 03:24 AM
Re: Login Scripts
[Re: NTDOC]
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
It was working when I posted it.
Its not working now, but ill get to that...
|
Top
|
|
|
|
#203043 - 2011-09-07 03:43 AM
Re: Login Scripts
[Re: Redback]
|
Redback
Getting the hang of it
Registered: 2002-03-20
Posts: 71
Loc: Albury Wodonga, Australia
|
Tracked down my problem, my kixforms stuff doesn't work with kixtart 4.62
runs fine with 4.61
*shrug*
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 323 anonymous users online.
|
|
|