#147240 - 2005-09-07 12:55 AM
display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
I have been having a heck of a time trying to figure out how to break a loop that displays information to the user that something is installing or running at a particular point in the login script. The ideal outcome would be to have the loop terminate upon the program finishing and then continue through the login script. Below is an example that I created when spybot is running or installing. Any help would be appreciated. If this has come up before then my apologies.
Kevin
do
$ = SetTitle ("/ ...Please Wait Spybot - Search & Destroy is Scanning for spyware! /") Sleep (1) $ = SetTitle ("- ...Please Wait Spybot - Search & Destroy is Scanning for spyware! -") Sleep (1) $ = SetTitle ("\ ...Please Wait Spybot - Search & Destroy is Scanning for spyware! \") Sleep (1) $ = SetTitle ("| ...Please Wait Spybot - Search & Destroy is Scanning for spyware! |") Sleep (1) AT (12,10) " ...Please Wait, @FULLNAME " AT (14,10) " / Spybot - Search & Destroy is Scanning for spyware! /" Sleep (1) AT (12,10) " " AT (14,10) "- Spybot - Search & Destroy is Scanning for spyware! -" ;Sleep (1) AT (12,10) " " AT (14,10) "\ Spybot - Search & Destroy is Scanning for spyware! \" ;Sleep (1) AT (12,10) " " AT (14,10) "| Spybot - Search & Destroy is Scanning for spyware! |" Sleep (1)
Until $spybotfinished=1
|
Top
|
|
|
|
#147242 - 2005-09-07 04:08 AM
Re: display progress or activity while installing or running a program
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
If you want to show a progress meter, there are examples using KiXForms (http://kixforms.org ) that should work fine.
Kent
|
Top
|
|
|
|
#147243 - 2005-09-07 04:37 AM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
Believe me I would rather run the program in the background and just go silent. The problem is these users don't want to wait for spybot to finish or think the script is locked up so they control alt delete and end the kix script. My users ar too smart for their own good! I need to have spybot finish the scan before the script completes since it draws near 100 cpu utilization. When I used the run command instead of the shell command spybot would lock up the pc if the user clicked on an app during the scan. The scan can take up to 3 minutes or longer on the old machines so there lies the problem. I thought about a logoff script but have no idea how to make it work with windows 98.
|
Top
|
|
|
|
#147244 - 2005-09-07 04:58 AM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
I appreciate the advice but I couldn't find anything on the site that pertained. Maybe they trimmed the fat since you were there last
|
Top
|
|
|
|
#147246 - 2005-09-07 09:07 AM
Re: display progress or activity while installing or running a program
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
There are three options that spring to mind:
- Detach the spybot process and let it run in the background don't bother to inform the user.
- Detach the spybot process and let it run, give the user something to watch while it it running.
- Don't detach the spybot process, give the user something to watch while it is running.
Of these the first is the best option of course. To detach a process use "RUN", not "SHELL". You might also need to use the DOS shell "START" command to force the process to detach.
If you want to detach the process and display information to your user, you will need to use one of the process tracking UDFs to monitor it.
If you want to halt the main script, then you must start a seperate "progress" script before you call the spybot process. Your main script will then need to signal the progress script to stop by using the registry or a file or it might simply kill the progress script.
|
Top
|
|
|
|
#147247 - 2005-09-07 02:01 PM
Re: display progress or activity while installing or running a program
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Quote:
The problem is these users don't want to wait for spybot to finish or think the script is locked up so they control alt delete and end the kix script.
Leave "Break Off" and your users won't be doing the end task thing too many times.
|
Top
|
|
|
|
#147248 - 2005-09-07 02:35 PM
Re: display progress or activity while installing or running a program
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
display "Spybot is currently scanning your computer, yada yada" and detach it with a RUN statement
then use a While Loop around EnumProcess() around a 3-5 second delay. During each loop have it display a "." so it looks like progress.
It would look something like this: (not real code)
? "Spybot is currently scanning your computer" run '"path to spybot.exe" /switches' while enumprocess('spybot.exe') '.' sleep 5 loop
|
Top
|
|
|
|
#147250 - 2005-09-07 05:35 PM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
Thanks for the great idea but I must be missing something. The loop works but does not terminate when spybot finishes. Any ideas.
Kevin
|
Top
|
|
|
|
#147252 - 2005-09-08 04:36 AM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
Lonkero' this is what I got. Also 'I am testing this code on a win9x machine. Does this make a difference? Anyway what do you think could be wrong? Spybotsd.exe is the process name under xp.
run "'C:\Progra~1\Spybot~1\SpybotSD.exe' /taskbarhide /autocheck /autofix /autoclose" while enumprocess('spybotsd.exe')
AT (13,10) " ...Please Wait, @FULLNAME " AT (15,10) " / Spybot - Search & Destroy is Scanning for spyware! / " Sleep (1) AT (13,10) " " AT (15,10) "- Spybot - Search & Destroy is Scanning for spyware! - " Sleep (1) AT (13,10) " " AT (15,10) "\ Spybot - Search & Destroy is Scanning for spyware! \ " Sleep (1) AT (13,10) " " AT (15,10) "| Spybot - Search & Destroy is Scanning for spyware! | " Sleep (1) Loop
Edited by 2manyhats (2005-09-08 04:43 AM)
|
Top
|
|
|
|
#147255 - 2005-09-08 10:18 AM
Re: display progress or activity while installing or running a program
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Win9x? You're not likely to have too much success with Win9x.
I've tidied your code up a little: Code:
Break ON Dim $sProgressChars,$iEnumProcess, $sSpybot $sProgressChars="/-\|" $sSpybot="spybotsd.exe" At(13,10) " ...Please Wait, "+@FULLNAME Run "'C:\Progra~1\Spybot~1\"+$sSpybot+"' /taskbarhide /autocheck /autofix /autoclose" $iEnumProcess=EnumProcess($sSpybot) While 0<$iEnumProcess At(15,10) " "+Left($sProgressChars,1)+" ["+$iEnumProcess+"] Spybot - Search & Destroy is Scanning for spyware! "+Left($sProgressChars,1)+" " Sleep(0.3) $sProgressChars=SubStr($sProgressChars,2)+Left($sProgressChars,1) $iEnumProcess=EnumProcess($sSpybots) Loop
When running you should see the spybot.exe process number between the "[]" characters on the screen.
The problem with Win9x is that it has a completely different kernel, so it doesn't support all the process control that NT+ does.
You will need WMI installed on each machine as well for enumprocess() to work - WMI is not available on NT or Win9x as standard, you need to install an add-on.
If you cannot be sure of your clients, then here is a method which should work for all of them.
This requires two scripts. A progress script which just displays a progress bar on the screen and your main script which calls the progress script.
The main script will stop when it calls the SpybotSD, but the progress script will continue to update the screen.
When SpybotSD finished you main script will continue, at which point it tells the progress script to close down.
Here is an example:
PROGRESS.KIX Code:
Break ON Dim $sProgressChars,$vDiscard ; NB, $sKey, $sValue, $iX, $iY and $sTitle are passed on the command line $sProgressChars="/-\|" While ReadValue($sKey,$sValue)<>"STOP" At($iX,$iY) Left($sProgressChars,1)+$sTitle+Left($sProgressChars,1) Sleep(0.25) $sProgressChars=SubStr($sProgressChars,2)+Left($sProgressChars,1) Loop ; Remove value - lets main script know we've closed $vDiscard=DelValue($sKey,$sValue) Exit 0
MAIN.KIX Code:
Break ON $=SetOption("Explicit","ON") CLS Dim $sKeyPress,$vDiscard Dim $sKey, $sValue, $sTitle, $iX, $iY
$sKey="HKCU\Software\KiXtart\ProgressBar" $sValue=@TIME+"."+@MSECS $sTitle="Spybot Seach & Destroy Scan in Progress" $iX=15 $iY=(80-2-Len($sTitle))/2 ; Start progress bar RUN 'Kix32.exe "'+@SCRIPTDIR+'/progress.kix"' +' $$sKey="'+$sKey+'"' +' $$sValue="'+$sValue+'"' +' $$iX="'+$iX+'"' +' $$iY="'+$iY+'"' +' $$sTitle="'+$sTitle+'"' At(0,1) "Main script will now pause until you hit a key:" Get $sKeyPress ; Tell progress script to stop. $vDiscard=WriteValue($sKey,$sValue,"STOP","REG_SZ") While ReadValue($sKey,$sValue)="STOP" Sleep 0.1 Loop CLS "Main script completed." ?
|
Top
|
|
|
|
#147257 - 2005-09-09 04:53 AM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
Richard, I want to thank you for all the great advice and time you spent on my post. I did not have time to implement the code for main.kix or progress.kix yet but I did try the version of my originally submitted code that you cleaned up for me. The enumprocess part of the script worked since the loop started and stopped properly but, for some reason the name of the process immediately trails the end of the first line displayed on the screen listed below. Is this normal?
------------------------------------------------- Code: -------------------------------------------------
Lastly, the line below did not show at all. Wierd.
------------------------------------------------- Code: At(15,10) " "+Left($sProgressChars,1)+" ["+$iEnumProcess+"] Spybot - Search & Destroy is Scanning for spyware! "+Left($sProgressChars,1)+" " -------------------------------------------------
Edited by 2manyhats (2005-09-09 04:57 AM)
|
Top
|
|
|
|
#147258 - 2005-09-09 10:12 AM
Re: display progress or activity while installing or running a program
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
In that case you don't have EnumProcess() in your script.
EnumProcess() is a udf, not a KiXtart built-in.
You can find EnumProcess() here
You will need to copy it and paste it into your script - you can just tack it to the bottom of the script.
The process name is appearing on the screen because that is the default behaviour for KiXtart when it gets data it doesn't know how else to handle - like when a user defined function is not properly defined.
The message isn't displaying because the EnumProcess() call fails and the result is "empty" - this is effectively the same result as when the process you are monitoring has stopped.
|
Top
|
|
|
|
#147259 - 2005-09-25 06:26 AM
Re: display progress or activity while installing or running a program
|
2manyhats
Fresh Scripter
Registered: 2005-09-07
Posts: 33
|
Well I finally got back to this little project. I think mart must have been right. I must have done something wrong with enumprocess(). I just started over in a clean script. This snippit works, but is not as nice as your code, Richard. I had problems getting your code to work and am still trying to figure out why. I will eventually.
I had to terminate cmd.exe since I guess enumprocess passes the window from kix32 to a dos shell. At least that's what it looks like. I tried to call other scripts after the enumprocess and the called scripts did execute but I still needed to terminate cmd.exe. This is what I came up with.
Code:
run "C:\Program Files\Spybot - Search & Destroy\spybotsd.exe /taskbarhide /autoupdate /autoclose" cls While enumprocess('spybotsd.exe') $ = SetTitle ("/ ...Please Wait Spybot - Search & Destroy is Scanning for spyware! /") AT (13,10) " ...Please Wait, @FULLNAME " AT (15,10) "/ Spybot - Search & Destroy is Scanning for spyware! / " Sleep(0.1) $ = SetTitle ("- ...Please Wait Spybot - Search & Destroy is Scanning for spyware! -") AT (13,10) " " AT (15,10) "- Spybot - Search & Destroy is Scanning for spyware! - " Sleep(0.1) $ = SetTitle ("\ ...Please Wait Spybot - Search & Destroy is Scanning for spyware! \") AT (13,10) " " AT (15,10) "\ Spybot - Search & Destroy is Scanning for spyware! \ " Sleep(0.1) $ = SetTitle ("| ...Please Wait Spybot - Search & Destroy is Scanning for spyware! |") AT (13,10) " " AT (15,10) "| Spybot - Search & Destroy is Scanning for spyware! | " Sleep(0.1) loop enumprocess(cmd.exe,1)
Edited by 2manyhats (2005-09-25 06:41 AM)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|