Not exiting at eof
Author |
Message |
Thuged_Out_G
|
Posted: Thu Aug 10, 2006 7:13 pm Post subject: Not exiting at eof |
|
|
code: |
proc listProcess
if not Sys.Exec ("C:\\WINNT\\system32\\cmd /k tasklist /svc >> c:\\test.txt") then
put Error.LastMsg
end if
var file : string := "C:\\test.txt"
var fileNum : int
var input : string
open : fileNum, file, get
loop
exit when eof (fileNum)
get : fileNum, input : *
put input
end loop
close : fileNum
end listProcess
|
Can someone please explain why that loop isnt stopping at eof, it just continually reads the file, over and over. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Thuged_Out_G
|
Posted: Thu Aug 10, 2006 9:16 pm Post subject: (No subject) |
|
|
Ok, got the loop issue figured out ... another problem arrises, which im unsure as to the best way to deal with.
code: |
var win := Window.Open ("title:win")
var file : string := "C:\\test1.txt"
var fileNum : int
var input : string
var inputChar : string
var sys : int
var ch := '"q"'
View.Set ("text")
proc getProcess
open : fileNum, file, write
close : fileNum
if not Sys.Exec ("C:\\WINNT\\system32\\cmd.exe /k tasklist /svc >> C:\\test1.txt") then
put Error.LastMsg
end if
end getProcess
proc listProcess
delay (5000)
open : fileNum, file, get
loop
exit when eof (fileNum)
get : fileNum, input : *
put input
end loop
close : fileNum
end listProcess
proc killProcess
var PID : string
put "Enter the PID of the process you would like to end: " ..
get PID
if not Sys.Exec ("C:\\WINNT\\system32\\cmd.exe /k ntsd -p " + PID + " -c " + ch) then
put Error.LastMsg
end if
end killProcess
getProcess
listProcess
killProcess
|
That is my code, my problem is after listProcess is called, im left with a command prompt, the same issue after I kill a process.
Does anyone know of a way I could close each command prompt after the the command is executed. |
|
|
|
|
![](images/spacer.gif) |
NikG
|
Posted: Thu Aug 10, 2006 10:25 pm Post subject: (No subject) |
|
|
Thuged_Out_G wrote: if not Sys.Exec ("C:\\WINNT\\system32\\cmd.exe /k tasklist /svc >> C:\\test1.txt") then
... Use the /c parameter instead of the /k. That should terminate the window after it's done doing what it supposed to.
(Just a note, I found that by typing in "help cmd" into the command prompt.) |
|
|
|
|
![](images/spacer.gif) |
Thuged_Out_G
|
Posted: Fri Aug 11, 2006 7:19 am Post subject: (No subject) |
|
|
code: |
if not Sys.Exec ("C:\\WINNT\\system32\\cmd.exe /k tasklist /svc >> C:\\test1.txt&&exit")
|
Is what I found, i'll try the /c those when I get home .. thanks!
Also, I was told on a website article that using the above ntsd command I could kill any process, Although try to kill certain processes always comes back with a access denied message. |
|
|
|
|
![](images/spacer.gif) |
|
|