#170135 - 2006-11-06 10:58 PM
Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
Hi,
this is a follow up from the "Logon Scripts" thread which was started by me. I am now having a lot of trouble editing the logon script to make a piece of text change to something different.
Code:
;*************************************************************** ;*************************************************************** ;** ;** NetCare3.2 - D5PS2Z0J Login System ;** Netlogon.kix ;** D5PS2Z0J NetServices ;** ;** Dependencies: ;** ;** Kixforms.dll ;** ;** $strVersion = "V.3.2.09" ;** ;*************************************************************** ;***************************************************************
;** Dim some global vars. Dim $frmForm Dim $fraBanner, $fraForm ;Dim $prgProgress Dim $Hour
;** Set some global vars.
$LSD = @LServer + "\netlogon" $WaitTime = 1 ;** Time to wait after each task $DoProgressCalls = 25 ;** Maximum times DoProgress is called $Step = 100/$DoProgressCalls ;** Increment progress bar $Blanker = " " ;** Blank captions
;**************** ;** START HERE ** ;***************
Gosub "CheckDLL" Gosub "DOFORM"
$frmForm.Show Call "$LSD\prep.kix" Call "$LSD\MapDrives.kix" Call "$LSD\DoAudit.kix" Call "$LSD\LogUser.kix" Call "$LSD\DoAntiVirus.kix" Call "$LSD\time.kix" Call "$LSD\snd.kix" Exit 1
;************* ;**END HERE ** ;*************
;************************************************************* ;** SUBS BELOW ** ;*************************************************************
:CheckDLL
;***************************************** ;** Check that KIXFORMS.DLL is registered and ** ;** copy and register if not ** ;*****************************************
$ReturnCode = KEYEXIST("HKEY_CLASSES_ROOT\KixTart.Form\CLSID")
IF $ReturnCode = 0 ;** KixForms not registered ;** Copy .DLL $SourceFile = @LServer + "\netlogon\kixforms.dll" $Value = ReadValue( "HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") $Destination = ExpandEnvironmentVars( $Value ) COPY $SourceFile $Destination ;** Register .DLL silently $CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll" $ObjShell = CreateObject("WScript.Shell") $ObjShell.run($CMDLine, 1, true) ;** Kill shell object $ObjShell = nothing ENDIF ;** Wait for registration to take effect sleep 2 RETURN
:DoProgress
$prgProgress.value = $prgProgress.value + $Step
Return
:DOFORM
;*************** ;** Main form ** ;*************** $frmForm = CREATEOBJECT("Kixtart.FORM") $frmForm.Caption = ("NetCare3.2 - D5PS2Z0J Logon System ") $frmForm.sysMenu = 0 $frmForm.Height = 300 $frmForm.Width = 450 $frmForm.FontName = "Verdana" $frmForm.FontSize = 9 $frmForm.center
;************* ;** Banner ** ;************* $fraBanner = $frmForm.PictureBox ;$fraBanner.IMAGE = "C:\my projects\NetCare3\Images\NC32SM.gif" $fraBanner.BACKCOLOR = $frmForm.RGB(255,255,255) $fraBanner.WIDTH = $frmForm.width - 4 $fraBanner.HEIGHT = 60 $fraBanner.LEFT = -2 $fraBanner.TOP = -2 ;** Draw On the banner ** $fraBanner.FONTSIZE = 14 $fraBanner.FONTNAME = "verdana" $fraBanner.FONTBOLD = 1 $fraBanner.FONTITALIC = 1 $fraBanner.ForeColor = $frmForm.RGB(0, 0, 200) $fraBanner.PrintXY (10,0,"Netlogon.kix") $fraBanner.FontItalic = 0 $fraBanner.FONTSIZE = 8 $fraBanner.ForeColor = $frmForm.RGB(0,0,0) $fraBanner.PrintXY (10,24,$strVersion +" Powered by KiXforms (Shamil Nunhuck) ") $fraBanner.FONTSIZE = 9 $fraBanner.PrintXY (10,35,"D5PS2Z0J NetServices") $fraBanner.FONTBOLD = 0 $fraBanner.FONTSIZE = 10 ;****************** ;** Progress Bar ** ;****************** $prgProgress = $frmForm.ProgressBar $prgProgress.width = $frmForm.width - 10 $prgProgress.left = 2 $prgProgress.height = 20 $prgProgress.top = 245;$frmForm.height - $prgProgress.height - 5 $prgProgress.style = 1 ;**************** ;** Main Frame ** ;**************** $fraMain = $frmForm.PictureBox $fraMain.BACKCOLOR = $frmForm.RGB(255,255,255) $fraMain.WIDTH = $frmForm.width $fraMain.HEIGHT = 182 ;$frmForm.height - $fraBanner.height - 35 $fraMain.LEFT = -2 $fraMain.TOP = $fraBanner.Height - 5 $lblJob = $fraMain.label $lblJob.FONTSIZE = 10 $lblJob.top = 80 $lblJob.width = 440 ;fraMain.width - 20 $lblJob.left = 10 $lblTask = $fraMain.label $lblTask.FONTSIZE = 10 $lblTask.top = 120 $lblTask.width = 440 ;fraMain.width - 20 $lblTask.left = 50 ;** Draw on the frame ** ;** Greeting $Hour = val(trim(left(@Time,2))) If $Hour < 12 $Greeting = "Good Morning @userid " else if $Hour < 17 $Greeting = "Good Afternoon @userid" else $Greeting = "Good Evening @userid " endif endif $fraMain.FONTSIZE = 11 $fraMain.FONTNAME = "verdana" $fraMain.FONTBOLD = 1 $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,10,$Greeting) $fraMain.printXY (10,40,"Please wait while you logon script executes...")
Return
;******************************* ;******************************* ;** END OF FILE ** ;******************************* ;*******************************
I need to change the Please wait while you logon script executes to Logon has been successful in the final code that is called.
Code:
$lblTask.Caption = $Blanker $lblTask.Caption = " " play file @ldrive+"chimes.wav" sleep 2 $prgProgress.value = $prgProgress.value + 5
|
Top
|
|
|
|
#170137 - 2006-11-07 02:00 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Hi 04nunhucks, Are you saying you want the script to start with, "Please wait while your logon script executes...", then when the script has completed, change it to, "Logon has been successful"?
There are many things in your script that should be changed, but I do not wish to offend, If you are open to constructive criticism I would be glad to help.
|
Top
|
|
|
|
#170138 - 2006-11-07 05:56 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
Benny69: I would love to hear constructive critisism; helps the learning process. (I know about Kixshell instead of Wshell)
|
Top
|
|
|
|
#170139 - 2006-11-07 06:29 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
What version of KiXforms are you using? You should be using the latest, it is version 2.46.54.0. You can get it here: http://www.kixforms.org/forum/viewtopic.php?t=503
If you do not know what version you are using, run this script.
Code:
Break On
$System = CreateObject("Kixtart.System") If Not $System $nul= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",262160) Quit() EndIf
$Form = $System.Form() $Form.Text = 'KiXforms.Classic Version' $Form.Size = 300,100
$Lbl = $Form.Controls.Label() $Lbl.Text = 'KiXforms.Classic Version '+$system.Version $Lbl.TextAlign = 32 $Lbl.Dock = 'Fill'
$Form.Show
While $Form.Visible $nul= Execute($Form.DoEvents) Loop Exit 0
Goto and GoSub can cause problems and can make it difficult to follow a script when you need to modify your script 6 months or a year later. They should be converted to User Defined Functions (UDFs). How to use UDFs can be found here: http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=81594&an=0&page=0#81594 How to write a UDF can be found here: http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=81656&an=0&page=0#81656
Do your users have Admin rights on there machines? If they do not, this code will not work:
Code:
$ReturnCode = KEYEXIST("HKEY_CLASSES_ROOT\KixTart.Form\CLSID")
IF $ReturnCode = 0 ;** KixForms not registered ;** Copy .DLL $SourceFile = @LServer + "\netlogon\kixforms.dll" $Value = ReadValue( "HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") $Destination = ExpandEnvironmentVars( $Value ) COPY $SourceFile $Destination ;** Register .DLL silently $CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll" $ObjShell = CreateObject("WScript.Shell") $ObjShell.run($CMDLine, 1, true) ;** Kill shell object $ObjShell = nothing ENDIF ;** Wait for registration to take effect sleep 2
If they do, it should be converted to a UDF and placed at the end of the script. This is your CheckDll converted to a function: Code:
Function CheckDLL() ;************************************************* ;** Check that KIXFORMS.DLL is registered and ** ;** copy and register if not ** ;************************************************* ;$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\KixTart.Form\CLSID") $ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID") If $ReturnCode = 0 ;** KixForms not registered ;** Copy .DLL $SourceFile = @LServer + "\netlogon\kixforms.dll" $Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") $Destination = ExpandEnvironmentVars($Value) Copy $SourceFile $Destination ;** Register .DLL silently $CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll" $ObjShell = CreateObject("WScript.Shell") $ObjShell.run($CMDLine, 1, true) ;** Kill shell object $ObjShell = "" EndIf ;** Wait for registration to take effect Sleep 2 EndFunction
To call the function use this code: Code:
CheckDLL()
Code containing forms should be placed at the beginning of the script. UDFs should be placed at the end of the script. I have moved the form code to the beginning.
I have changed this line: Code:
$ReturnCode = KEYEXIST("HKEY_CLASSES_ROOT\KixTart.Form\CLSID")
To: Code:
$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID")
“KiXtart.Form” is outdated and has been replaced with “KiXtart.System”
With that said, the KiXforms Object should be created like this: Code:
$System = CreateObject("Kixtart.System")
After the KiXforms Object is created you should verify that it was actually created, if it was not created it is more than likely that the KiXforms.dll is not installed. Here is the suggested code: Code:
If Not $System $nul= MessageBox("KiXforms Not Initiated."+@CRLF+ "Please Verify KiXforms.dll is installed."+@CRLF+ "This Script Will Now Close.","Error...",16) Quit() EndIf
In your code you are using ‘GoSub DoProgress’ to increment the ProgressBar.Value, this should be converted to a UDF. Change these lines: Code:
:DoProgress
$prgProgress.value = $prgProgress.value + $Step
Return
To: Code:
Function DoProgress() $prgProgress.Value = $prgProgress.Value + $Step EndFunction
And move the function to the end of the script.
Changing the “GoSub DoProgress” to a function, this line: Code:
GoSub DoProgress
Will need to be changed to: Code:
DoProgress()
In every other script that you are calling.
The .Caption property is out dated and should be replaced with the .Text property.
This line: Code:
$frmForm.Caption = ("NetCare3.2 - D5PS2Z0J Logon System ")
Should be replaced with this line: Code:
$frmForm.Text = "NetCare3.2 - D5PS2Z0J Logon System "
The parentheses should not be used.
The .Center property should be move to just before showing the form. This line: Code:
$frmForm.center
Should be moved here: Code:
$frmForm.Center $frmForm.Show
In the older versions of KiXforms, Controls were created like you have done here: Code:
$fraBanner = $frmForm.PictureBox
In the current versions Controls should be created like this: Code:
$fraBanner = $frmForm.Controls.Add("PictureBox")
For forms to function correctly there needs to be a loop that checks for form events. This code should be placed after showing the form. This is the suggested code: Code:
While $frmForm.Visible $=Execute($frmForm.DoEvents()) Loop
When the form Exits it should exit with a 0 not a 1, the reason for this is to show that the form exited with out errors. Code:
Exit 0
In your code you call these other scripts: Code:
Call "$LSD\prep.kix" Call "$LSD\MapDrives.kix" Call "$LSD\DoAudit.kix" Call "$LSD\LogUser.kix" Call "$LSD\DoAntiVirus.kix" Call "$LSD\time.kix" Call "$LSD\snd.kix"
With all the changes suggested, it might be a good idea for you to post these scripts one at time for us to review and help you perfect the code.
This code should be placed after calling this other scripts, and before exiting the script, to be able to change the text you want to change use this format: Code:
$fraMain.ForeColor = $fraMain.BackColor $fraMain.PrintXY (10,40,"Please wait while you logon script executes...") $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,40,"Logon has been successful.")
To exit the form I have added this function: Code:
Function ExitScript() Quit() EndFunction
It should be called after the text has been changed, to call it use this code: Code:
ExitScript()
Here is your updated code: Code:
;*************************************************************** ;*************************************************************** ;** ;** NetCare3.2 - D5PS2Z0J Login System ;** Netlogon.kix ;** D5PS2Z0J NetServices ;** ;** Dependencies: ;** ;** Kixforms.dll Ver 2.46.54.0 ;** ;** ;** ;*************************************************************** ;***************************************************************
;** Dim some global vars. Dim $frmForm Dim $fraBanner, $fraForm ;Dim $prgProgress Dim $Hour
;** Set some global vars.
$strVersion = "V.3.2.09" $LSD = @LServer + "\netlogon" $WaitTime = 1 ;** Time to wait after each task $DoProgressCalls = 25 ;** Maximum times DoProgress is called $Step = 100/$DoProgressCalls ;** Increment progress bar $Blanker = " " ;** Blank captions
;****************** ;** START HERE ** ;******************
CheckDLL()
;Create KiXforms Object $System = CreateObject("Kixtart.System") ;Verify KiXforms Object was created If Not $System $nul= MessageBox("KiXforms Not Initiated."+@CRLF+ "Please Verify KiXforms.dll is installed."+@CRLF+ "This Script Will Now Close.","Error...",16) Quit() EndIf
;*************** ;** Main form ** ;***************
$frmForm = $System.Form() $frmForm.Text = "NetCare3.2 - D5PS2Z0J Logon System " $frmForm.SysMenu = 0 $frmForm.Height = 300 $frmForm.Width = 450 $frmForm.FontName = "Verdana" $frmForm.FontSize = 9
;************* ;** Banner ** ;************* $fraBanner = $frmForm.Controls.Add("PictureBox") ;$fraBanner.Image = "C:\my projects\NetCare3\Images\NC32SM.gif" $fraBanner.BackColor = $frmForm.RGB(255,255,255) $fraBanner.Width = $frmForm.Width - 4 $fraBanner.Height = 60 $fraBanner.Left = -2 $fraBanner.Top = -2
;** Draw On the banner ** $fraBanner.FontSize = 14 $fraBanner.FontName = "verdana" $fraBanner.FontBold = 1 $fraBanner.FontItalic = 1 $fraBanner.ForeColor = $frmForm.RGB(0, 0, 200) $fraBanner.PrintXY (10,0,"Netlogon.kix") $fraBanner.FontItalic = 0 $fraBanner.FontSize = 8 $fraBanner.ForeColor = $frmForm.RGB(0,0,0) $fraBanner.PrintXY (10,24,$strVersion +" Powered by KiXforms (Shamil Nunhuck) ") $fraBanner.FontSize = 9 $fraBanner.PrintXY (10,35,"D5PS2Z0J NetServices") $fraBanner.FontBold = 0 $fraBanner.FontSize = 10
;****************** ;** Progress Bar ** ;****************** $prgProgress = $frmForm.Controls.Add("ProgressBar") $prgProgress.Width = $frmForm.Width - 10 $prgProgress.Left = 2 $prgProgress.Height = 20 $prgProgress.Top = 245;$frmForm.Height - $prgProgress.Height - 5 $prgProgress.Style = 1
;**************** ;** Main Frame ** ;**************** $fraMain = $frmForm.Controls.Add("PictureBox") $fraMain.BackColor = $frmForm.RGB(255,255,255) $fraMain.Width = $frmForm.Width $fraMain.Height = 182 ;$frmForm.Height - $fraBanner.Height - 35 $fraMain.Left = -2 $fraMain.Top = $fraBanner.Height - 5
$lblJob = $fraMain.Controls.Add("label") $lblJob.FontSize = 10 $lblJob.Top = 80 $lblJob.Width = 440 ;fraMain.Width - 20 $lblJob.Left = 10
$lblTask = $fraMain.Controls.Add("label") $lblTask.FontSize = 10 $lblTask.Top = 120 $lblTask.Width = 440 ;fraMain.Width - 20 $lblTask.Left = 50
;** Draw on the frame ** ;** Greeting $Hour = Val(Trim(Left(@Time,2))) If $Hour < 12 $Greeting = "Good Morning @userid " Else If $Hour < 17 $Greeting = "Good Afternoon @userid" Else $Greeting = "Good Evening @userid " EndIf EndIf $fraMain.FontSize = 11 $fraMain.FontName = "verdana" $fraMain.FontBold = 1 $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,10,$Greeting) $fraMain.PrintXY (10,40,"Please wait while you logon script executes...") $frmForm.Center $frmForm.Show
;Call "$LSD\prep.kix" ;Call "$LSD\MapDrives.kix" ;Call "$LSD\DoAudit.kix" ;Call "$LSD\LogUser.kix" ;Call "$LSD\DoAntiVirus.kix" ;Call "$LSD\time.kix" ;Call "$LSD\snd.kix"
Sleep 2 $fraMain.ForeColor = $fraMain.BackColor $fraMain.PrintXY (10,40,"Please wait while you logon script executes...") $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,40,"Logon has been successful.") Sleep 2 ExitScript()
While $frmForm.Visible $=Execute($frmForm.DoEvents()) Loop Exit 0
;************** ;** END HERE ** ;**************
Function CheckDLL() ;************************************************* ;** Check that KIXFORMS.DLL is registered and ** ;** copy and register if not ** ;************************************************* ;$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\KixTart.Form\CLSID") $ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID") If $ReturnCode = 0 ;** KixForms not registered ;** Copy .DLL $SourceFile = @LServer + "\netlogon\kixforms.dll" $Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") $Destination = ExpandEnvironmentVars($Value) Copy $SourceFile $Destination ;** Register .DLL silently $CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll" $ObjShell = CreateObject("WScript.Shell") $ObjShell.run($CMDLine, 1, true) ;** Kill shell object $ObjShell = "" EndIf ;** Wait for registration to take effect Sleep 2 EndFunction
Function DoProgress() $prgProgress.Value = $prgProgress.Value + $Step EndFunction
Function ExitScript() Quit() EndFunction
;******************************* ;******************************* ;** END OF FILE ** ;******************************* ;*******************************
|
Top
|
|
|
|
#170140 - 2006-11-07 06:50 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
Here are each of the files that are called for the netlogon process
MapDrives.kix
Code:
;************************************************ ;** MapDrives.kix D5PS2Z0J Systems ** ;** ** ;** 25/05/2005 V1.00 ** ;** ** ;************************************************
$lblJob.caption = $Blanker $lblJob.caption = "Mapping Network Drives... " USE * /DELETE
;** Common mappings: Everyone gets these **
Sleep $WaitTime $prgProgress.value = $prgProgress.value + 5
$DriveToMap = "\\d5ps2z0j\PUBLIC" $lblTask.Caption = $Blanker $lblTask.Caption = "Public" USE L: $DriveToMap $prgProgress.value = $prgProgress.value + 5
$DriveToMap = "\\d5ps2z0j\netlogon" $lblTask.Caption = $Blanker $lblTask.Caption = "netlogon" USE N: $DriveToMap $prgProgress.value = $prgProgress.value + 5 $DriveToMap = "\\d5ps2z0j\cache" $lblTask.Caption = "SmartCache" USE S: $DriveToMap $prgProgress.value = $prgProgress.value + 5 ; RETURN
DoAudit.kix
Code:
;************************************************ ;** DoAudit.kix JD5PS2Z0J SYSTEMS ** ;** ** ;** V1.00 ** ;** ** ;************************************************
$fraMain.fontsize = 10 $lblJob.caption = $Blanker $lblJob.caption = "Running Workstation Audit... " ;AUDIT STUFF IN HERE ; ;Audit what???? ; ; Hardware: (Check for changes?) ; Installed Software (Check for changes?) $lblTask.Caption = $Blanker $lblTask.Caption = "Hardware" sleep $WaitTime $prgProgress.value = $prgProgress.value + 20 $lblTask.Caption = $Blanker $lblTask.Caption = "Software" sleep $WaitTime $prgProgress.value = $prgProgress.value + 20
;Return
LogUser.kix
Code:
;************************************************ ;** LogUser.kix ** ;** ** ;** ** ;** ** ;************************************************ $lblJob.caption = $Blanker $lblJob.caption = "Collecting Logon Info... " $prgProgress.value = $prgProgress.value + $Step
;** Dim some
vars $LogFolder = @LServer + "\netlogon\logs\"
;** Path to log dir $FileName = @MONTH + "--" + @WKSTA + ".csv"
;** Get Log File Name $MyFile = $LogFolder + $FileName
;** Set full path to file $CRLF= Chr(13) + Chr(10)
;** Set Carriage Return + Line feed $MyDateTime = @DATE + " : " + @TIME
;** Date and time string $prgProgress.value = $prgProgress.value + 10 IF OPEN(1,$MyFile,5) = 0
;** Open file for write. Create if doesn't exist
;**
Date and time $Silent = WriteLine (1, $MyDateTime + $CRLF) $lblTask.Caption = $Blanker $lblTask.Caption = "Time and Date" sleep $WaitTime $prgProgress.value = $prgProgress.value + $Step
;**
User Details $Silent = WriteLine (1, "User: " + @USERID + " Full
Name: " + @FULLNAME + $CRLF);Write data to file $lblTask.Caption = $Blanker $lblTask.Caption = "User Name" sleep $WaitTime $prgProgress.value = $prgProgress.value + 10
;** IP
0 $Silent = WriteLine (1, "IP: " + @IPAddress0 + $CRLF)
$lblTask.Caption = $Blanker $lblTask.Caption = "IP Address" sleep $WaitTime $prgProgress.value = $prgProgress.value + 20 $Silent = WriteLine (1, $CRLF) $Silent = Close (1) ;Close file ENDIF ; Sleep 1 ;Return
DoAntiVirus.kix
Code:
;:DoAntiVirus
$lblJob.caption = $Blanker $lblJob.caption = "Updating Antivirus... "
$lblTask.Caption = $Blanker
$LSD = @LServer + "\Netlogon" IF Exist("$LSD\patches.kix") Call "$LSD\patches.kix" endif
$prgProgress.value = $prgProgress.value + $Step
;Return
time.kix
Code:
;======= Sync Time with Domain Controller ;Sync Time
$lblJob.caption = $Blanker $lblJob.caption = "Synchronizing time " If Exist ("$LSD\TimeSync.bat") Shell "$COMSPEC /e:1024 /c $LSD\TimeSync.bat" EndIf
snd.kix Code:
$lblJob.caption = $Blanker $lblJob.caption = "Logon has been successful" play file @ldrive+"chimes.wav" sleep 2 $prgProgress.value = $prgProgress.value + 5
|
Top
|
|
|
|
#170141 - 2006-11-07 07:13 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
You should convert each of these scripts to functions, then add them to the end of the main script.
You should alter the DoProgress function to this: Code:
Function DoProgress($Step) $prgProgress.Value = $prgProgress.Value + $Step EndFunction
Then in each script change these lines from: Code:
$prgProgress.value = $prgProgress.value + 5
To: Code:
DoProgress(5)
This will allow you to pass variables into functions.
You will need to change all of the .Caption properties in all of the scripts to the .Text property.
When you have that completed post your completed script for further review.
|
Top
|
|
|
|
#170142 - 2006-11-07 08:48 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
DoAntiVirus.kix DoAntiVirus.kix
Code:
;:DoAntiVirus
$lblJob.Text = $Blanker $lblJob.Text = "Updating Antivirus... "
$lblTask.Text = $Blanker
$LSD = @LServer + "\Netlogon" IF Exist("$LSD\patches.kix") Call "$LSD\patches.kix" endif
Function DoProgress($Step) DoProgress(5) EndFunction ;Return
Doaudit.kix
Code:
;************************************************ ;** DoAudit.kix JD5PS2Z0J SYSTEMS ** ;** ** ;** V1.00 ** ;** ** ;************************************************
$fraMain.fontsize = 10 $lblJob.Text = $Blanker $lblJob.Text = "Running Workstation Audit... " ;AUDIT STUFF IN HERE ; ;Audit what???? ; ; Hardware: (Check for changes?) ; Installed Software (Check for changes?) $lblTask.Text = $Blanker $lblTask.Text = "Hardware" sleep $WaitTime Function DoProgress($Step) DoProgress (20) EndFunction
$lblTask.Text = $Blanker $lblTask.Text = "Software" sleep $WaitTime Function DoProgress($Step) DoProgress (20) EndFunction
;Return
LogUser.kix
Code:
;************************************************ ;** LogUser.kix ** ;** ** ;** ** ;** ** ;************************************************ $lblJob.Text = $Blanker $lblJob.Text = "Collecting Logon Info... " $prgProgress.value = $prgProgress.value + $Step
;** Dim some vars $LogFolder = @LServer + "\netlogon\logs\" ;** Path to log dir $FileName = @MONTH + "--" + @WKSTA + ".csv" ;** Get Log File Name $MyFile = $LogFolder + $FileName ;** Set full path to file $CRLF= Chr(13) + Chr(10) ;** Set Carriage Return + Line feed $MyDateTime = @DATE + " : " + @TIME ;** Date and time string Function DoProgress($Step) DoProgress (10) EndFunction IF OPEN(1,$MyFile,5) = 0 ;** Open file for write. Create if doesn't exist ;** Date and time $Silent = WriteLine (1, $MyDateTime + $CRLF) $lblTask.Text = $Blanker $lblTask.Text = "Time and Date" sleep $WaitTime Function DoProgress($Step) DoProgress (10) EndFunction ;** User Details $Silent = WriteLine (1, "User: " + @USERID + " Full Name: " + @FULLNAME + $CRLF);Write data to file $lblTask.Text = $Blanker $lblTask.Text = "User Name" sleep $WaitTime Function DoProgress($Step) DoProgress (10) EndFunction ;** IP 0 $Silent = WriteLine (1, "IP: " + @IPAddress0 + $CRLF) $lblTask.Text = $Blanker $lblTask.Text = "IP Address" sleep $WaitTime Function DoProgress($Step) DoProgress (10) EndFunction $Silent = WriteLine (1, $CRLF) $Silent = Close (1) ;Close file ENDIF ; Sleep 1 ;Return
MapDrives.kix
Code:
;************************************************ ;** MapDrives.kix D5PS2Z0J Systems ** ;** ** ;** 25/05/2005 V1.00 ** ;** ** ;************************************************
$lblJob.Text = $Blanker $lblJob.Text = "Mapping Network Drives... " USE * /DELETE
;** Common mappings: Everyone gets these **
Sleep $WaitTime Function DoProgress($Step) DoProgress (5) EndFunction
$DriveToMap = "\\d5ps2z0j\PUBLIC" $lblTask.Text = $Blanker $lblTask.Text = "Public" USE L: $DriveToMap Function DoProgress($Step) DoProgress (5) EndFunction
$DriveToMap = "\\d5ps2z0j\netlogon" $lblTask.Text = $Blanker $lblTask.Text = "netlogon" USE N: $DriveToMap Function DoProgress($Step) DoProgress (5) EndFunction $DriveToMap = "\\d5ps2z0j\cache" $lblTask.Text = "SmartCache" USE S: $DriveToMap Function DoProgress($Step) DoProgress (5) EndFunction ; RETURN
snd.kix
Code:
$lblJob.Text = $Blanker $lblJob.Text = "Logon has been successful" play file @ldrive+"chimes.wav" sleep 2 Function DoProgress($Step) DoProgress (5) EndFunction
time.kix
Code:
;======= Sync Time with Domain Controller ;Sync Time
$lblJob.Text = $Blanker $lblJob.Text = "Synchronizing time " If Exist ("$LSD\TimeSync.bat") Shell "$COMSPEC /e:1024 /c $LSD\TimeSync.bat" EndIf
|
Top
|
|
|
|
#170143 - 2006-11-07 09:05 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
None of the scripts seem to like
Code:
DoProgress (5)
|
Top
|
|
|
|
#170144 - 2006-11-07 09:13 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
In my first review of your script I mention two Links How to use UDFs and How to write a UDF please read these then correct the function code that you just posted.
|
Top
|
|
|
|
#170145 - 2006-11-07 09:39 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Here is one of you scripts, DoAntiVirus.kix Code:
;:DoAntiVirus
$lblJob.Text = $Blanker $lblJob.Text = "Updating Antivirus... "
$lblTask.Text = $Blanker
$LSD = @LServer + "\Netlogon" IF Exist("$LSD\patches.kix") Call "$LSD\patches.kix" endif
Function DoProgress($Step) DoProgress(5) EndFunction ;Return
Converted correctly this is the way it should look: Code:
Function DoAntiVirus() $lblJob.Text = $Blanker $lblJob.Text = "Updating Antivirus... " $lblTask.Text = $Blanker $LSD = @LServer + "\Netlogon" If Exist("$LSD\patches.kix") Call "$LSD\patches.kix" EndIf DoProgress(5) EndFunction
Then in these lines: Code:
Call "$LSD\prep.kix" Call "$LSD\MapDrives.kix" Call "$LSD\DoAudit.kix" Call "$LSD\LogUser.kix" Call "$LSD\DoAntiVirus.kix" Call "$LSD\time.kix" Call "$LSD\snd.kix"
you have this line: Code:
Call "$LSD\DoAntiVirus.kix"
Change it to: Code:
DoAntiVirus()
So those lines will now look like: Code:
Call "$LSD\prep.kix" Call "$LSD\MapDrives.kix" Call "$LSD\DoAudit.kix" Call "$LSD\LogUser.kix" DoAntiVirus() Call "$LSD\time.kix" Call "$LSD\snd.kix"
Do the same thing with the other scripts.
a function will only appear once in a script, it is used many times over, so this function: Code:
Function DoProgress($Step) $prgProgress.Value = $prgProgress.Value + $Step EndFunction
Will only appear once in you script. Functions are never defined inside other Functions, they can be called but never defined.
|
Top
|
|
|
|
#170146 - 2006-11-07 10:26 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
Hi,
I have done that will all scripts however, when run, I recieve an error telling me that there is an unknown command. This error refers to prep () as not being a known command.
|
Top
|
|
|
|
#170147 - 2006-11-07 11:04 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
please post the the entire script now that all of these changes have been applied.
|
Top
|
|
|
|
#170149 - 2006-11-08 10:02 AM
Re: Change Text on Dialog
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
Hey, no kidding. Great job stepping up to the plate Benny.
I thought I had already voted for you, but I suppose with the loss of my account last week that information is gone.
Have a 5 star on me too. 
|
Top
|
|
|
|
#170150 - 2006-11-08 01:29 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Ah,... guys, you make me blush  That is very kind of you, Thanks Guys.
|
Top
|
|
|
|
#170151 - 2006-11-08 05:00 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
04nunhucks, Out of all the external scripts that you posted i do not see '$LSD\prep.kix', my guess is that it has not been converted to a function and then added to the main script.
|
Top
|
|
|
|
#170152 - 2006-11-08 06:09 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
Here is the code
Code:
Function prep () $lblJob.Text = $Blanker $lblJob.Text = "Preparing for logon" sleep 1
EndFunction
Could you refresh my memory on how to convert script to function.
|
Top
|
|
|
|
#170153 - 2006-11-08 06:24 PM
Re: Change Text on Dialog
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
it looks like it is already a function, can you post your updated script?
|
Top
|
|
|
|
#170154 - 2006-11-08 06:40 PM
Re: Change Text on Dialog
|
04nunhucks
Getting the hang of it
Registered: 2006-09-08
Posts: 66
|
netlogon script? the script above is the updated script like I have done for all other scrips. Code:
;*************************************************************** ;*************************************************************** ;** ;** NetCare3.2 - D5PS2Z0J Login System ;** Netlogon.kix ;** D5PS2Z0J NetServices ;** ;** Dependencies: ;** ;** Kixforms.dll Ver 2.46.54.0 ;** ;** ;** ;*************************************************************** ;***************************************************************
;** Dim some global vars. Call "$LSD\functions.kix" Dim $frmForm Dim $fraBanner, $fraForm ;Dim $prgProgress Dim $Hour
;** Set some global vars.
$strVersion = "V.3.2.09" $LSD = @LServer + "\netlogon" $WaitTime = 1 ;** Time to wait after each task $DoProgressCalls = 25 ;** Maximum times DoProgress is called $Step = 100/$DoProgressCalls ;** Increment progress bar $Blanker = " " ;** Blank captions
;****************** ;** START HERE ** ;******************
CheckDLL()
;Create KiXforms Object $System = CreateObject("Kixtart.System") ;Verify KiXforms Object was created If Not $System $nul= MessageBox("KiXforms Not Initiated."+@CRLF+ "Please Verify KiXforms.dll is installed."+@CRLF+ "This Script Will Now Close.","Error...",16) Quit() EndIf
;*************** ;** Main form ** ;***************
$frmForm = $System.Form() $frmForm.Text = "NetCare3.2 - D5PS2Z0J Logon System " $frmForm.SysMenu = 0 $frmForm.Height = 300 $frmForm.Width = 450 $frmForm.FontName = "Verdana" $frmForm.FontSize = 9
;************* ;** Banner ** ;************* $fraBanner = $frmForm.Controls.Add("PictureBox") ;$fraBanner.Image = "C:\my projects\NetCare3\Images\NC32SM.gif" $fraBanner.BackColor = $frmForm.RGB(255,255,255) $fraBanner.Width = $frmForm.Width - 4 $fraBanner.Height = 60 $fraBanner.Left = -2 $fraBanner.Top = -2
;** Draw On the banner ** $fraBanner.FontSize = 14 $fraBanner.FontName = "verdana" $fraBanner.FontBold = 1 $fraBanner.FontItalic = 1 $fraBanner.ForeColor = $frmForm.RGB(0, 0, 200) $fraBanner.PrintXY (10,0,"Netlogon.kix") $fraBanner.FontItalic = 0 $fraBanner.FontSize = 8 $fraBanner.ForeColor = $frmForm.RGB(0,0,0) $fraBanner.PrintXY (10,24,$strVersion +" Powered by KiXforms (Shamil Nunhuck) ") $fraBanner.FontSize = 9 $fraBanner.PrintXY (10,35,"D5PS2Z0J NetServices") $fraBanner.FontBold = 0 $fraBanner.FontSize = 10
;****************** ;** Progress Bar ** ;****************** $prgProgress = $frmForm.Controls.Add("ProgressBar") $prgProgress.Width = $frmForm.Width - 10 $prgProgress.Left = 2 $prgProgress.Height = 20 $prgProgress.Top = 245;$frmForm.Height - $prgProgress.Height - 5 $prgProgress.Style = 1
;**************** ;** Main Frame ** ;**************** $fraMain = $frmForm.Controls.Add("PictureBox") $fraMain.BackColor = $frmForm.RGB(255,255,255) $fraMain.Width = $frmForm.Width $fraMain.Height = 182 ;$frmForm.Height - $fraBanner.Height - 35 $fraMain.Left = -2 $fraMain.Top = $fraBanner.Height - 5
$lblJob = $fraMain.Controls.Add("label") $lblJob.FontSize = 10 $lblJob.Top = 80 $lblJob.Width = 440 ;fraMain.Width - 20 $lblJob.Left = 10
$lblTask = $fraMain.Controls.Add("label") $lblTask.FontSize = 10 $lblTask.Top = 120 $lblTask.Width = 440 ;fraMain.Width - 20 $lblTask.Left = 50
;** Draw on the frame ** ;** Greeting $Hour = Val(Trim(Left(@Time,2))) If $Hour < 12 $Greeting = "Good Morning @userid " Else If $Hour < 17 $Greeting = "Good Afternoon @userid" Else $Greeting = "Good Evening @userid " EndIf EndIf $fraMain.FontSize = 11 $fraMain.FontName = "verdana" $fraMain.FontBold = 1 $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,10,$Greeting) $fraMain.PrintXY (10,40,"Please wait while you logon script executes...") $frmForm.Center $frmForm.Show
prep() MapDrives() DoAudit() LogUser() DoAntiVirus() time.kix() snd.kix()
Sleep 2 $fraMain.ForeColor = $fraMain.BackColor $fraMain.PrintXY (10,40,"Please wait while you logon script executes...") $fraMain.ForeColor = $frmForm.RGB(0,100,100) $fraMain.PrintXY (10,40,"Logon has been successful.") Sleep 2 ExitScript()
While $frmForm.Visible $=Execute($frmForm.DoEvents()) Loop Exit 0
;************** ;** END HERE ** ;**************
Function CheckDLL() ;************************************************* ;** Check that KIXFORMS.DLL is registered and ** ;** copy and register if not ** ;************************************************* ;$ReturnCode = KeyExist("HKEY_CLASSES_ROOT\KixTart.Form\CLSID") $ReturnCode = KeyExist("HKEY_CLASSES_ROOT\Kixtart.System\CLSID") If $ReturnCode = 0 ;** KixForms not registered ;** Copy .DLL $SourceFile = @LServer + "\netlogon\kixforms.dll" $Value = ReadValue("HKLM\System\CurrentControlset\Control\Windows", "SystemDirectory") $Destination = ExpandEnvironmentVars($Value) Copy $SourceFile $Destination ;** Register .DLL silently $CMDLine = "regsvr32 /s " + $Destination + "\kixforms.dll" $ObjShell = CreateObject("WScript.Shell") $ObjShell.run($CMDLine, 1, true) ;** Kill shell object $ObjShell = "" EndIf ;** Wait for registration to take effect Sleep 2 EndFunction
Function DoProgress() $prgProgress.Value = $prgProgress.Value + $Step EndFunction
Function ExitScript() Quit() EndFunction
;******************************* ;******************************* ;** END OF FILE ** ;******************************* ;*******************************
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2141 anonymous users online.
|
|
|