Replaces the command " tasklist "

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Replaces the command " tasklist "

#1 Post by ReAslan » 04 Jun 2015 02:41

Does anyone know if there is a command for Windows 2000 that replaces the command " tasklist ".

"tasklist > %tempfile%" Command used to write to a file processes in the task. But on Windows 2000 I do not write anything while it works on XP.

I tried to use the commands " PuList " and " tlist " but do not function.

I await an answer thanks

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#2 Post by npocmaka_ » 04 Jun 2015 02:48

qprocess / query process -if you have terminal services.

wmic process get - if you have wmic

the last resort are the wmic objects which should be accessible with vbscrtip/jscript/

EDIT - for windows 2000 windows script host is available as additional download (needed for vbscript/jescript ) - https://www.microsoft.com/en-us/downloa ... x?id=20240

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#3 Post by ReAslan » 04 Jun 2015 03:25

Then I have to write the code that is this :

@echo off

set tempfile=bdw.txt

del %tempfile%
tasklist > %tempfile%

type %tempfile% | find /i "iexplore.exe"

if errorlevel 0 if not errorlevel 1 goto IsRunning
start iexplore

exit
del %tempfile%
pause
exit

:IsRunning
echo IsRunning

goto exit

:loop
taskkill /im "iexplore.exe" /fi "STATUS eq NOT RESPONDING" /f >nul && start "" "C:\Programmi\Internet Explorer\iexplore.exe"
goto loop


On Windows XP works perfectly on Windows 2000 I do not write the file so it does not work processes .

I also tried the command that you told me but I can not get it going . Still does not write to the file

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#4 Post by npocmaka_ » 04 Jun 2015 03:48

open a command prompt and check if the command
query process
will produce error.

if not download the windows script host from the link in my previous comment and I'll create a script that list the processes with their pids.
Also you can check if MSHTA command can be ran - if yes there'll be no need to download the WSH.


I totally don't know what the win2000 is capable of as it is pretty ancient .

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#5 Post by ReAslan » 04 Jun 2015 04:10

I tried to install the executable over and nothing has changed .
I tried to run the cmd " query process " and by mistake while " MSHTA " does not give me no errors but does nothing .

I do not know how to find a command instead of " tasklist " for Windows 2000. Other ideas ? :( :( :(

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#6 Post by npocmaka_ » 04 Jun 2015 04:12

So you have mshta.

Save this as a .bat and run it in the console and check its output:

Code: Select all

@if (@X)==(@Y) @end /* JSCRIPT COMMENT **
@echo off

setlocal
rem if "%~1" equ "" echo pass the process name as forst argument && exit /b 1
:: first argument is the process you want to check if running

rem set process_to_check=%~1
mshta "about:<script language='javascript' src='file://%~dpnxf0'></script>"|more

rem mshta "about:<script language='javascript' src='file://%~dpnxf0'></script>" | find /i "%process_to_check%" >nul 2>&1 && (
rem     echo process %process_to_check%  is running
rem ) || (
rem     echo process %process_to_check%  is not running
rem )
endlocal
exit /b
************** end of JSCRIPT COMMENT **/


   var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1);


   var winmgmts = GetObject("winmgmts:\\\\.\\root\\cimv2");
   var colProcess = winmgmts.ExecQuery("Select * from Win32_Process");
   var processes =  new Enumerator(colProcess);
   for (;!processes.atEnd();processes.moveNext()) {
    var process=processes.item();
    fso.Write( process.processID + "   " + process.Name + "\n");
   }
   close();

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#7 Post by ReAslan » 04 Jun 2015 04:35

Then output it gives me is what's in the picture :http://uploadpie.com/iFAlx

Then I do not understand that command should put instead of tasklist after you run this script .

Sorry for the inconvenience and thank you.

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#8 Post by npocmaka_ » 04 Jun 2015 04:38

looks like the mshta wont help here... :?

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#9 Post by ReAslan » 04 Jun 2015 04:45

In what sense it should help . I replace this code : " tasklist > % tempfile % " with this " mshta > % % tempfile "???

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#10 Post by npocmaka_ » 04 Jun 2015 05:05

it should display all running processes bus is not capable to do it on win2000.

I have no idea what else could help - may be compiled windwos 2000 resource tool kit - https://support.microsoft.com/en-us/kb/927229 and pulist

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#11 Post by ReAslan » 04 Jun 2015 06:19

It does not work even after installing the executable " PuList " and putting as line of code : " pulist > % tempfile % "

I do not know how to treat the problem :(

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Replaces the command " tasklist "

#12 Post by npocmaka_ » 04 Jun 2015 06:34

check if the pulist is the the %path%
or easier - put the executable in the same directory as the script or where console is opened.

Honestly I have no idea what to suggest more. Better update your windows.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Replaces the command " tasklist "

#13 Post by foxidrive » 04 Jun 2015 08:36

Did you try pslist from Sysinternals

Mark Russinovich - Sysinternals

ReAslan
Posts: 11
Joined: 28 May 2015 03:10

Re: Replaces the command " tasklist "

#14 Post by ReAslan » 04 Jun 2015 08:55

Yes but does not work.
I try it with this syntax : " pslist > % tempfile % "
You mean like this ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Replaces the command " tasklist "

#15 Post by foxidrive » 04 Jun 2015 08:59

ReAslan wrote:Yes but does not work.
I try it with this syntax : " pslist > % tempfile % "
You mean like this ?


What do you see on the cmd screen when you type

Code: Select all

pslist


Do you see a list of the processes? You need to download pslist.

Post Reply