#128072 - 2004-10-18 09:44 PM
KiXform Help
|
Fugazi
Starting to like KiXtart
Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
|
Is there a way that I can break out of the runscripts function when the start button is pressed. It locks up until it completes all the the scripts in the ini file.
Code:
;===============================================================================================
;**** Last Modified on 10/18/2004 at 2:29:07 PM by dkrogol ****
;===============================================================================================
Break On
$System = CreateObject("Kixtart.System")
;KD START
;************* Form **************
$Form = $System.Form()
$Form.BackColor = 192,192,192
$Form.ForeColor = 0,128,0
$Form.Height = 550
$Form.Left = 88
$Form.Text = "Company Laptop Utility - @fullname - @wksta"
$Form.Top = 104
$Form.Width = 700
;**************************************
;************* ListView **************
$ListView = $Form.Controls.ListView()
$ListView.Height = 472
$ListView.HeaderStyle = 2
$ListView.Left = 0
$ListView.Top = 30
$ListView.Width = 698
$ListView.OnDoubleClick = "readlog"
;**************************************
;************* startbutton **************
$startbutton = $Form.Controls.Button()
$startbutton.Cancel = "True"
$startbutton.Default = "True"
$startbutton.FlatStyle = 3
$startbutton.FontBold = "True"
$startbutton.Height = 22
$startbutton.Left = 15
$startbutton.Text = "Start"
$startbutton.ToolTipText = "Executes daily tasks"
$startbutton.Top = 4
$startbutton.Width = 69
$startbutton.OnClick = "runscripts()"
;**************************************
;************* Exit **************
$Exit = $Form.Controls.Button()
$Exit.FlatStyle = 3
$Exit.FontBold = "True"
$Exit.Height = 22
$Exit.Left = 615
$Exit.Text = "Exit "
$Exit.ToolTipText = "Exit application"
$Exit.Top = 4
$Exit.Width = 71
$Exit.OnClick = "Quit()"
;**************************************
;************* logo **************
$logo = $Form.Controls.PictureBox()
$logo.BackColor = 192,192,192
$logo.BorderStyle = 0
$logo.Height = 50
$logo.Left = 285
$logo.Picture = "c:\mtglaptop\bmp\logo1.bmp"
$logo.Top = 0
$logo.Width = 125
;**************************************
;************* user **************
$user = $Form.Controls.Label()
$user.BackColor = 192,192,192
$user.FontBold = "True"
$user.ForeColor = 0,0,0
$user.Height = 13
$user.Left = 105
$user.Text = "User: @fullname"
$user.Top = 9
$user.Width = 160
;**************************************
;************* PCName **************
$PCName = $Form.Controls.Label()
$PCName.BackColor = 192,192,192
$PCName.FontBold = "True"
$PCName.ForeColor = 0,128,64
$PCName.Height = 15
$PCName.Left = 15
$PCName.Text = "Computer Name: @wksta"
$PCName.Top = 510
$PCName.Width = 211
;**************************************
;************* ipaddress **************
$ipaddress = $Form.Controls.Label()
$ipaddress.BackColor = 192,192,192
$ipaddress.FontBold = "True"
$ipaddress.ForeColor = 0,128,0
$ipaddress.Height = 16
$ipaddress.Left = 510
$ipaddress.Text = "IP Address: @ipaddress0"
$ipaddress.Top = 510
$ipaddress.Width = 171
;**************************************
;************* Date_Day **************
$Date_Day = $Form.Controls.Label()
$Date_Day.BackColor = 192,192,192
$Date_Day.FontBold = "True"
$Date_Day.ForeColor = 0,128,0
$Date_Day.Height = 15
$Date_Day.Left = 285
$Date_Day.Text = "@day - @Monthno/@Mdayno/@year"
$Date_Day.Top = 502
$Date_Day.Width = 128
;**************************************
;KD END
$= $ListView.Columns.Add("Job",175)
$= $ListView.Columns.Add("Start",100)
$= $listview.Columns.Add("End",100)
$= $ListView.Columns.Add("Logfile",200)
$= $ListView.Columns.Add("Status",119)
$Form.Show
While $Form.Visible
$=Execute($System.Application.DoEvents())
$item=$listview.items.add
$Item.SubItems(0).Text = ("Session Completed Sucessfully")
Loop
Exit 1
Function runscripts ()
$form.Refresh()
Del "c:\mtglaptop\logs\*.*"
If Exist($inifile)
$ScriptArray = Split(ReadProfileString($inifile,"",""),Chr(10))
For Each $script in $ScriptArray
If Val(ReadProfileString($inifile,$script,"run"))
$starttime=@TIME
$message=ReadProfileString($inifile,$script,"message")
$log=ReadProfileString($inifile,$script,"log")
If $testrun=3
MessageBox ("Requestable job available. Do you want to run $message?","Requestable job",36,0)
EndIf
$item=$listview.items.add
$Item.SubItems(0).Text = ($message)
$Item.SubItems(1).Text = ($starttime);(@FULLNAME +"\"+ @USERID)
$Item.SubItems(3).Text = ($log)
$Item.SubItems(4).Text = ("Running")
Select
Case InStr ($script,".exe")
Shell $script
Case InStr ($script,".kix")
Call $script
EndSelect
Do
Sleep 0.5
Until
Exist ("c:\mtglaptop\logs\"+$log)
$Item.SubItems(2).Text=(@time)
$Item.SubItems(4).Text=("Complete")
EndIf
Next
EndFunction
Edited by Fugazi (2004-10-18 09:51 PM)
_________________________
I haven't failed. I just found another way that did not work.
|
|
Top
|
|
|
|
#128079 - 2004-10-19 05:32 PM
Re: KiXform Help
|
Fugazi
Starting to like KiXtart
Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
|
I have changed the "$Exit.OnClick" to "ExitApp.OnClick"
Code:
$ExitApp.OnClick = "$$ExitApp.OnClick=1"
Code:
Function runscripts ()
Del "c:\mtglaptop\logs\*.log"
If Exist($inifile)
$ScriptArray = Split(ReadProfileString($inifile,"",""),Chr(10))
For Each $script in $ScriptArray
If Val(ReadProfileString($inifile,$script,"run"))
$leave=0
$starttime=@TIME
$message=ReadProfileString($inifile,$script,"message")
$log=ReadProfileString($inifile,$script,"log")
If $testrun=3
MessageBox ("Requestable job available. Do you want to run $message?","Requestable job",36,0)
EndIf
$item=$listview.items.add
$Item.SubItems(0).Text = ($message)
$Item.SubItems(1).Text = ($starttime);(@FULLNAME +"\"+ @USERID)
$Item.SubItems(3).Text = ($log)
$Item.SubItems(4).Text = ("Running")
Select
Case InStr ($script,".exe")
Shell $script
Case InStr ($script,".kix")
Call $script
EndSelect
Do
If $$ExitApp.OnClick =1
Quit()
EndIf
Until
Exist ("c:\mtglaptop\logs\"+$log)
$Item.SubItems(2).Text=(@time)
$Item.SubItems(4).Text=("Complete")
EndIf
Next
EndFunction
_________________________
I haven't failed. I just found another way that did not work.
|
|
Top
|
|
|
|
#128085 - 2004-10-19 10:31 PM
Re: KiXform Help
|
Fugazi
Starting to like KiXtart
Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
|
I have 2 scripts controling the program.
Laptop.kix
;This script will keep kixtart scripts and system files up to date
;and call the control script.
Break on
;SetConsole ("hide")
Global $localscripts,$netscripts,$workdir,$oralogon,$logpath,$netpath,
$locallog,$errmsg,$runerr,$clients,$logfile,$netlogs,$inifile
$workdir = "c:\mtglaptop\"
$localscripts = "c:\mtglaptop\scripts\"
$netscripts = "\\Server\Share\mtglaptop\scripts\"
$netpath = "\\Server\Share\mtglaptop\"
$netlogs="\\Server\Share\kixlogs\mtglaptop\@USERID\"
$oralogon = "c:\oracle\ora81\bin\sqlplus user/password" + Chr(64) + "database"
$locallog= "c:\mtglaptop\logs\"
$runerr="c:\mtglaptop\errmsg.kix"
$clients="\\Server\Share\clients\"
$inifile = "c:\mtglaptop\settings.ini"
If NOT Exist ($netpath +"control.kix")
$errmsg="Unable to contact SERVER."
Gosub error
EndIf
;VUIA = verify user is authorized
$veruser = ReadProfileString ($netpath + "vuia.dat",USER,@USERID)
Select
Case
$veruser="admin"
Case $veruser <> @WKSTA
$errmsg="INVALID USER-You are NOT authorized to run this application"
Gosub error
EndSelect
If NOT Exist ($localscripts)
MD $localscripts
EndIf
If NOT Exist ($netlogs)
MD $netlogs
EndIf
Del $workdir + "files.dat"
Del $locallog + "*.log"
$sysfile = CompareFileTimes ($netpath + "settings.ini", $workdir + "settings.ini")
Select
Case $sysfile = 1
Copy $netpath+"settings.ini" $workdir
Case $sysfile = -3
Copy $netpath+"settings.ini" $workdir
EndSelect
$sysfile = CompareFileTimes ($netpath + "control.kix", $workdir + "control.kix")
Select
Case $sysfile = 1
Copy $netpath+"control.kix" $workdir
Case $sysfile = -3
Copy $netpath+"control.kix" $workdir
EndSelect
Shell "%comspec% /e:1024 /c dir " + $netscripts + " /b > " + $workdir + "\files.dat"
Shell "%comspec% /e:1024 /c dir " + $localscripts + " /b >> " + $workdir + "\files.dat"
:filechk
If Open(1,$workdir+"files.dat",2)
"Error opening file list."+@CRLF
"Reason: ["+@ERROR+"] "+@SERROR+@CRLF
Else
$file=ReadLine(1)
While NOT @ERROR
$compare = CompareFileTimes($netscripts + $file,$localscripts+$file)
Select
Case $compare = 1
Copy $netscripts + $file $localscripts
?"Case 1 copying " + $netscripts + $file
Case $compare = -2
Del $localscripts + $file
?"Deleting " + $localscripts + $file
Case $compare = -3
Copy $netscripts + $file $localscripts
?"Case 2 copying " + $netscripts + $file
Case $compare = 0
?$file + " Did not need to be updated"
EndSelect
$file=ReadLine(1)
Loop
$=Close(1)
EndIf
Call $workdir +"control.kix"
Exit 0
:error
Call $runerr
Exit 0
Control.kix
Code:
;===============================================================================================
;**** Last Modified on 10/19/2004 at 3:22:45 PM by a021515 ****
;===============================================================================================
Break On
;SETOPTION('explicit','on')
$System = CreateObject("Kixtart.System")
;KD START
;************* Form **************
$Form = $System.Form()
$Form.BackColor = 192,192,192
$Form.ForeColor = 0,128,0
$Form.Height = 550
$Form.Left = 88
$Form.Text = "Company Laptop Utility - @fullname - @wksta"
$Form.Top = 104
$Form.Width = 700
$Form.DoEvents = ""
;**************************************
;************* ListView **************
$ListView = $Form.Controls.ListView()
$ListView.Height = 472
$ListView.HeaderStyle = 2
$ListView.Left = 0
$ListView.Top = 30
$ListView.Width = 698
$ListView.OnDoubleClick = ""
;**************************************
;************* startbutton **************
$startbutton = $Form.Controls.Button()
$startbutton.Cancel = "True"
$startbutton.Default = "True"
$startbutton.FlatStyle = 3
$startbutton.FontBold = "True"
$startbutton.Height = 22
$startbutton.Left = 15
$startbutton.Text = "Start"
$startbutton.ToolTipText = "Executes daily tasks"
$startbutton.Top = 4
$startbutton.Width = 69
$startbutton.OnClick = "runscripts()"
;**************************************
;************* ExitApp **************
$ExitApp = $Form.Controls.Button()
$ExitApp.FlatStyle = 3
$ExitApp.FontBold = "True"
$ExitApp.Height = 22
$ExitApp.Left = 610
$ExitApp.Text = "Exit "
$ExitApp.ToolTipText = "Exit application"
$ExitApp.Top = 4
$ExitApp.Width = 71
$ExitApp.OnClick = "$exitapp.tag = 1"
;**************************************
;************* logo **************
$logo = $Form.Controls.PictureBox()
$logo.BackColor = 192,192,192
$logo.BorderStyle = 0
$logo.Height = 50
$logo.Left = 285
$logo.Picture = "c:\mtglaptop\bmp\logo1.bmp"
$logo.Top = 0
$logo.Width = 125
;**************************************
;************* user **************
$user = $Form.Controls.Label()
$user.BackColor = 192,192,192
$user.FontBold = "True"
$User.ForeColor = 0,0,0
$user.Height = 13
$user.Left = 105
$user.Text = "User: @fullname"
$user.Top = 9
$user.Width = 160
;**************************************
;************* PCName **************
$PCName = $Form.Controls.Label()
$PCName.BackColor = 192,192,192
$PCName.FontBold = "True"
$PCName.ForeColor = 0,128,64
$PCName.Height = 15
$PCName.Left = 15
$PCName.Text = "Computer Name: @wksta"
$PCName.Top = 510
$PCName.Width = 211
;**************************************
;************* ipaddress **************
$ipaddress = $Form.Controls.Label()
$ipaddress.BackColor = 192,192,192
$ipaddress.FontBold = "True"
$ipaddress.ForeColor = 0,128,0
$ipaddress.Height = 16
$ipaddress.Left = 510
$ipaddress.Text = "IP Address: @ipaddress0"
$ipaddress.Top = 510
$ipaddress.Width = 171
;**************************************
;************* Date_Day **************
$Date_Day = $Form.Controls.Label()
$Date_Day.BackColor = 192,192,192
$Date_Day.FontBold = "True"
$Date_Day.ForeColor = 0,128,0
$Date_Day.Height = 15
$Date_Day.Left = 285
$Date_Day.Text = "@day-@Monthno/@Mdayno/@year"
$Date_Day.Top = 502
$Date_Day.Width = 128
;**************************************
?$ExitApp.OnClick
;KD END
$= $ListView.Columns.Add("Job",175)
$= $ListView.Columns.Add("Start",100)
$= $listview.Columns.Add("End",100)
$= $ListView.Columns.Add("Logfile",200)
$= $ListView.Columns.Add("Status",119)
$Form.Show
While $Form.Visible
$=Execute($System.Application.DoEvents())
$item=$listview.items.add
$Item.SubItems(0).Text = ("Session Completed Sucessfully")
Loop
Exit 1
Function runscripts ()
Del "c:\mtglaptop\logs\*.log"
If Exist($inifile)
$ScriptArray = Split(ReadProfileString($inifile,"",""),Chr(10))
For Each $script in $ScriptArray
If Val(ReadProfileString($inifile,$script,"run"))
$starttime=@TIME
$message=ReadProfileString($inifile,$script,"message")
$log=ReadProfileString($inifile,$script,"log")
If $testrun=3
MessageBox ("Requestable job available. Do you want to run $message?","Requestable job",36,0)
EndIf
$item=$listview.items.add
$Item.SubItems(0).Text = ($message)
$Item.SubItems(1).Text = ($starttime);(@FULLNAME +"\"+ @USERID)
$Item.SubItems(3).Text = ($locallog + $log)
$Item.SubItems(4).Text = ("Running")
Select
Case InStr ($script,".exe")
Shell $script
Case InStr ($script,".kix")
Call $script
EndSelect
EndIf
Do
sleep 0.5
If $exitapp.tag = 1
$=Execute($Form.DoEvents)
$item=$listview.items.add
$Item.SubItems(0).Text = ("User Aborted Session")
$ExitApp.Tag = "1"
Quit 1
EndIf
Until
Exist ($locallog+$log)
$Item.SubItems(2).Text=(@time)
$Item.SubItems(4).Text=("Complete")
Next
EndFunction
Edited by Fugazi (2004-10-19 11:08 PM)
_________________________
I haven't failed. I just found another way that did not work.
|
|
Top
|
|
|
|
#128088 - 2004-10-20 10:38 AM
Re: KiXform Help
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1452 anonymous users online.
|
|
|