Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CMD Process Manager..
22-06-2011, 10:10 AM, (This post was last modified: 22-06-2011, 10:11 AM by mikicun.)
Post: #1
Tongue  CMD Process Manager..
heh... aku pon nak bagi satu program lama yang aku buat dulu... (lam tahun 2008...)
time tuh tengah aktif terer wat script nih...
cuba edit kasi update sket... kot2 ada idea baru yang lebih power...

nih batch script dier...
Code:
@echo off
:intro
rem this line is for background and font color...
color 3f
mode 48,50
setlocal ENABLEDELAYEDEXPANSION
Title CMD Process Manager
:Begin
PUSHD
CD /D "!TEMP!"
set "TASKLIST=%windir%\system32\tasklist.exe"
set "FIND=%windir%\system32\find.exe"
set "wmic=%windir%\System32\Wbem\wmic.exe"
set "Explore=%windir%\explorer.exe"
set offset=
set sorder=

:Reload
cls
set num=0
echo.-----------------------------------------------
echo.[Process Name]       [PID]     [MEM]  [CPUTime]
echo.-----------------------------------------------
if not defined NAME set NAME=%USERNAME%
if "!NAME!"=="ALL~PROCS" (
  !TASKLIST! /FO TABLE /NH /V | SORT !offset! !sorder! >"plist.txt"
) else (
  !TASKLIST! /FI "USERNAME eq !NAME!" /FO TABLE /NH /V | SORT !offset! !sorder! >"plist.txt"
)
for /f "tokens=*" %%a in (plist.txt) do (
set /a num+=1
set "tempvar=%%a"
set "list=!tempvar:~0,20! !tempvar:~27,5! !tempvar:~60,9!K!tempvar:~141,10!"
echo.!list!
)
Del /f /q "plist.txt" >nul 2>&1
echo.
echo.----------------------------------------------
if "!NAME!"=="ALL~PROCS" (
  echo.All Processes - [!num!] Process Running
) else (
  echo.!NAME! - [!num!] Process Running
)
echo.----------------------------------------------
echo.
if not defined ac (
if /i "!NAME!"=="%USERNAME%" goto :MNG
if /i "!NAME!"=="SYSTEM" goto :MNG
if /i "!NAME!"=="ALL~PROCS" goto :MNG
)
if /i "!ac!"=="K" goto :Kill
if /i "!ac!"=="A" goto :ALLPROCS
if /i "!ac!"=="S" goto :SYSTEM
if /i "!ac!"=="U" goto :USER
if /i "!ac!"=="E" goto :Explore
if /i "!ac!"=="X" goto :End
if /i "!ac!"=="N" goto :SNAME
if /i "!ac!"=="P" goto :SPID
if /i "!ac!"=="M" goto :SMEM
if /i "!ac!"=="C" goto :SCPU
set "ac="
GOTO :Reload

:USER
set "NAME="
set "ac="
GOTO :Reload

:MNG
echo.Options:
echo.  Sort by: N=Name, P=PID,  M=MEM,      C=CPU
echo.  Show procs:      A=ALL,  S=System,   U=User
echo.  Functions:       K=Kill, E=Explore,  X=Exit
set /p "ac=Manage : "
GOTO :Reload

:ALLPROCS
set "NAME=ALL~PROCS"
set "ac="
GOTO :Reload

:SYSTEM
set NAME=SYSTEM
set "ac="
GOTO :Reload

:Kill
echo.Type PID to Kill..
set /p "PID=PID : "
if not defined PID goto :Reload
Taskkill /F /PID !PID! >nul 2>&1
if errorlevel 1 (echo.No Task Running w/ this PID.) else (
if !PID! geq 0 if !PID! lss 10 (
echo.Can't kill Critical Process
goto :clr_var2
) else (
echo.Success : Task with PID=!PID!
echo. has been KILLED..
))
:clr_var2
set "ac="
set "PID="
PAUSE>NUL
GOTO :Reload

:Explore
echo.Type PID to Explore..
set /p "PID=PID : "
if not defined PID goto :Reload
if !PID! lss 10 goto :clr_var
if !PID! gtr 10000 goto :clr_var
!wmic! process get ProcessID,ExecutablePath |  !FIND! "  !PID!" >"path.txt"
for /f "tokens=1* delims=," %%a in (path.txt) do (
set "tempvar=%%a"
set "tempvar=!tempvar:~0,67!"
for /f "tokens=1* delims=," %%b in ("!tempvar!") do set "exepath=%%~dpb"
)
if not defined exepath (
echo.No Task Running w/ this PID.
PAUSE>NUL
) else (
!Explore! ""!exepath!""
)
set "ac="
:clr_var
set "PID="
set "exepath="
Del /f /q "path.txt" >nul 2>&1
GOTO :Reload

:SNAME
set offset=
set sorder=
set "ac="
GOTO :Reload

:SPID
set "offset=/+27"
set sorder=
set "ac="
GOTO :Reload

:SMEM
set "offset=/+60"
set "sorder=/R"
set "ac="
GOTO :Reload

:SCPU
set "offset=/+141"
set "sorder=/R"
set "ac="
GOTO :Reload

:END
:mode 120,50
color 07

aku post gak script nih kat tempat len dulu... depa modofied gila2 dari kancil jadi ferari... huhu..
aku tabik abis kat forum derang tu...

.zip   pm.zip (Size: 1,31 KB / Downloads: 3)
Reply
22-06-2011, 11:44 AM,
Post: #2
RE: CMD Process Manager..
(22-06-2011, 10:10 AM)mikicun Wrote: heh... aku pon nak bagi satu program lama yang aku buat dulu... (lam tahun 2008...)
time tuh tengah aktif terer wat script nih...
cuba edit kasi update sket... kot2 ada idea baru yang lebih power...

nih batch script dier...
Code:
@echo off
:intro
rem this line is for background and font color...
color 3f
mode 48,50
setlocal ENABLEDELAYEDEXPANSION
Title CMD Process Manager
:Begin
PUSHD
CD /D "!TEMP!"
set "TASKLIST=%windir%\system32\tasklist.exe"
set "FIND=%windir%\system32\find.exe"
set "wmic=%windir%\System32\Wbem\wmic.exe"
set "Explore=%windir%\explorer.exe"
set offset=
set sorder=

:Reload
cls
set num=0
echo.-----------------------------------------------
echo.[Process Name]       [PID]     [MEM]  [CPUTime]
echo.-----------------------------------------------
if not defined NAME set NAME=%USERNAME%
if "!NAME!"=="ALL~PROCS" (
  !TASKLIST! /FO TABLE /NH /V | SORT !offset! !sorder! >"plist.txt"
) else (
  !TASKLIST! /FI "USERNAME eq !NAME!" /FO TABLE /NH /V | SORT !offset! !sorder! >"plist.txt"
)
for /f "tokens=*" %%a in (plist.txt) do (
set /a num+=1
set "tempvar=%%a"
set "list=!tempvar:~0,20! !tempvar:~27,5! !tempvar:~60,9!K!tempvar:~141,10!"
echo.!list!
)
Del /f /q "plist.txt" >nul 2>&1
echo.
echo.----------------------------------------------
if "!NAME!"=="ALL~PROCS" (
  echo.All Processes - [!num!] Process Running
) else (
  echo.!NAME! - [!num!] Process Running
)
echo.----------------------------------------------
echo.
if not defined ac (
if /i "!NAME!"=="%USERNAME%" goto :MNG
if /i "!NAME!"=="SYSTEM" goto :MNG
if /i "!NAME!"=="ALL~PROCS" goto :MNG
)
if /i "!ac!"=="K" goto :Kill
if /i "!ac!"=="A" goto :ALLPROCS
if /i "!ac!"=="S" goto :SYSTEM
if /i "!ac!"=="U" goto :USER
if /i "!ac!"=="E" goto :Explore
if /i "!ac!"=="X" goto :End
if /i "!ac!"=="N" goto :SNAME
if /i "!ac!"=="P" goto :SPID
if /i "!ac!"=="M" goto :SMEM
if /i "!ac!"=="C" goto :SCPU
set "ac="
GOTO :Reload

:USER
set "NAME="
set "ac="
GOTO :Reload

:MNG
echo.Options:
echo.  Sort by: N=Name, P=PID,  M=MEM,      C=CPU
echo.  Show procs:      A=ALL,  S=System,   U=User
echo.  Functions:       K=Kill, E=Explore,  X=Exit
set /p "ac=Manage : "
GOTO :Reload

:ALLPROCS
set "NAME=ALL~PROCS"
set "ac="
GOTO :Reload

:SYSTEM
set NAME=SYSTEM
set "ac="
GOTO :Reload

:Kill
echo.Type PID to Kill..
set /p "PID=PID : "
if not defined PID goto :Reload
Taskkill /F /PID !PID! >nul 2>&1
if errorlevel 1 (echo.No Task Running w/ this PID.) else (
if !PID! geq 0 if !PID! lss 10 (
echo.Can't kill Critical Process
goto :clr_var2
) else (
echo.Success : Task with PID=!PID!
echo. has been KILLED..
))
:clr_var2
set "ac="
set "PID="
PAUSE>NUL
GOTO :Reload

:Explore
echo.Type PID to Explore..
set /p "PID=PID : "
if not defined PID goto :Reload
if !PID! lss 10 goto :clr_var
if !PID! gtr 10000 goto :clr_var
!wmic! process get ProcessID,ExecutablePath |  !FIND! "  !PID!" >"path.txt"
for /f "tokens=1* delims=," %%a in (path.txt) do (
set "tempvar=%%a"
set "tempvar=!tempvar:~0,67!"
for /f "tokens=1* delims=," %%b in ("!tempvar!") do set "exepath=%%~dpb"
)
if not defined exepath (
echo.No Task Running w/ this PID.
PAUSE>NUL
) else (
!Explore! ""!exepath!""
)
set "ac="
:clr_var
set "PID="
set "exepath="
Del /f /q "path.txt" >nul 2>&1
GOTO :Reload

:SNAME
set offset=
set sorder=
set "ac="
GOTO :Reload

:SPID
set "offset=/+27"
set sorder=
set "ac="
GOTO :Reload

:SMEM
set "offset=/+60"
set "sorder=/R"
set "ac="
GOTO :Reload

:SCPU
set "offset=/+141"
set "sorder=/R"
set "ac="
GOTO :Reload

:END
:mode 120,50
color 07

aku post gak script nih kat tempat len dulu... depa modofied gila2 dari kancil jadi ferari... huhu..
aku tabik abis kat forum derang tu...

very nice batch script! i likee..
Reply
22-06-2011, 12:20 PM,
Post: #3
RE: CMD Process Manager..
boleh terangkan sikit x pasal batch script nie?
ape function dye..
n ape jadi kalau run?
Lai2 singgah blog saye --> http://keyboardexploit.blogspot.com/

[Image: bibornsignature.png]
Reply
22-06-2011, 12:56 PM,
Post: #4
RE: CMD Process Manager..
(22-06-2011, 12:20 PM)biborn Wrote: boleh terangkan sikit x pasal batch script nie?
ape function dye..
n ape jadi kalau run?

batch script ni run mcm cmd ko tu... full of cli... cmna nk buat? visual studio ader... sng skit la.... function dia ni seperti yg d nyatakan kat atas tu...proces manager/task manager...n kalo run, mcm task manager jgk ler..try... Big Grin

[ SHARING IS CARING ] Big Grin [ KNOWLEDGE ARE INFINITY ]
Reply
27-06-2011, 11:05 AM,
Post: #5
RE: CMD Process Manager..
(22-06-2011, 12:56 PM)Xander Wrote:
(22-06-2011, 12:20 PM)biborn Wrote: boleh terangkan sikit x pasal batch script nie?
ape function dye..
n ape jadi kalau run?

batch script ni run mcm cmd ko tu... full of cli... cmna nk buat? visual studio ader... sng skit la.... function dia ni seperti yg d nyatakan kat atas tu...proces manager/task manager...n kalo run, mcm task manager jgk ler..try... Big Grin

style2...mmg sgt berkesan pada pc sy yg acapkali hang...
Reply
27-06-2011, 12:42 PM,
Post: #6
RE: CMD Process Manager..
nih yg dah diupdate oleh site lain...
ganazzzz.....
[Image: unlediel.jpg]

klau nak boleh aku upload kan...
Reply


Forum Jump: