#171781 - 2006-12-20 10:55 AM
ReadLine issue - tasklist-wrapper SOLVED
|
Björn
Korg Regular
Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
|
I'm toying around with a script, that will use tasklist, and/or taskkill / start a task. But, encountered a problem I have no idea how to solve. I think the issue is within my creation of the temporary-file. Please look for yourself and any hints, tips etc are as always welcome. sidenote: running with 4.53.
If NOT @LOGONMODE
Break On
EndIf
Dim $SO,$command,$procserv
$SO = SetOption("Explicit","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("NoMacrosInStrings","On")
$command = 'tasklist'
$procserv = 'winamp'
dim $Rnd,$TempPath,$TempFile,$Handle,$ReadLine
SRND(@MSECS)
$Rnd = RND
$TempPath = ExpandEnvironmentVars('%temp%')
$Handle = FreeFileHandle()
if instr(right($TempPath,1),'\')
$TempFile = $TempPath + $Rnd + '.txt'
else
$TempFile = $TempPath +'\'+ $Rnd + '.txt'
endif
shell 'cmd.exe /C ' + $command + ' > ' + $TempFile
if Open($Handle,$TempFile) = 0
$ReadLine = ReadLine($Handle)
while @ERROR = 0
if instr($ReadLine,$procserv) 'Found '+ $ReadLine ' ? endif
$ReadLine = ReadLine($Handle)
loop
close($Handle)
endif
Edit: forgot to mention - the issue is within the ReadLine, that just starts an infinite loop *_*, thus, readline never really reaches the file/ end of file.
Edited by Björn (2006-12-20 01:53 PM)
_________________________
as long as it works - why fix it? If it doesn't work - kix-it!
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|