forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Open Source]: Task Manager
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun May 02, 2004 6:53 pm    Post subject: Reply with quote

I just looked, and I guess I have to start beating my head against the wall too, because the only value I can retrieve from that dll is "0"... Sad
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Sun May 02, 2004 6:54 pm    Post subject: Reply with quote

The VDS runtime uses PSAPI to get tasks and modules under NT. (Under 95 it uses ToolHelp.) So I'm not sure what you'd gain by this, although you can probably do more with the DLL than the use VDS makes of it.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun May 02, 2004 6:58 pm    Post subject: Reply with quote

You should also be able to get the memory usage of a task, which I tried but didn't get to work.. Sad
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun May 02, 2004 8:10 pm    Post subject: Reply with quote

I wish you could get all the cool info you can get with Windows Task Manager. Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Mon May 03, 2004 6:30 am    Post subject: Reply with quote

The following works on 9.x systems only due to the code used for CPU
stats.

This code is available for anyone to use, abuse, change, molest or
whatever... (VDS 5.x Code)

The images used in code can be found at:

http://garrett.vdsworld.com/misc

http://garrett.vdsworld.com/misc/misc.bmp
http://garrett.vdsworld.com/misc/dll.bmp
http://garrett.vdsworld.com/misc/exe.bmp
http://garrett.vdsworld.com/misc/taskh.bmp
http://garrett.vdsworld.com/misc/task.bmp
http://garrett.vdsworld.com/misc/sysicon.ico

Program icon:

http://garrett.vdsworld.com/misc/taskman.ico

Code:

  Option ErrorTrap,ErrorBranch
  Option Decimalsep,.
  Option Fieldsep,|
  Option Scale,96
  Option Sleeptime,250
  %%ProgramName = "VDS Task Manager "
  %%ProgramVersion = "1.0.0.1"
  %%ProgramDate = "27 April, 2003"
  %%FileName = "vdstaskman"
  %%RegdUser = "Freeware User"
  %%URL = "http://garrett.vdsworld.com/"
  %%Email = "N/A"
  %%SupportEmail = "N/A"
  %%CopyYear = "No copyright claimed, "
  %%Company = "Garrett R. Hylltun"
  TITLE %%ProgramName
  LoadLib kernel32.dll

  If @equal(%1,/T)
    GOTO RUNNEWTASK
  End
  If @equal(%1,/ER)
    GOTO ERRORDIALOG
  End
  If @equal(%1,/A)
    GOTO ABOUTBOX
  End
  If @equal(%1,/R)
    GOTO RECLNOW
  End

  Inifile Open,@path(%0)%%FileName".ini"
  %T = @iniread(Settings,T)
  %L = @iniread(Settings,L)
  %%Tab = @iniread(Settings,TAB)
  If @null(%T)
    %T = -1
    %L = 0
    %%Tab = 1
    Inifile Write,Settings,T,%T
    Inifile Write,Settings,L,%L
    Inifile Write,Settings,TAB,%%Tab
  End


  %%Limit = 2
  %7 = @regread(STATS,PerfStats\StartStat,KERNEL\CPUUsage)
  %7 = @regread(STATS,PerfStats\StartStat,KERNEL\Threads)
  DIALOG CREATE,VDS Task Manager,%T,%L,396,399,CLASS vdstaskmanAGER
  DIALOG ADD,STYLE,STYLE0A,MS Sans Serif,8,R,,
  DIALOG ADD,STYLE,STYLE0,MS Sans Serif,8,,,
  DIALOG ADD,STYLE,STYLE3,,,,BLACK,BLACK
  DIALOG ADD,STYLE,STYLE2,Arial,10,C,BLACK,LIME
  DIALOG ADD,STYLE,STYLE1,Arial,10,R,BLACK,LIME
  DIALOG ADD,TAB,TAB1,3,5,386,371,Applications|Processes|Performance
  DIALOG ADD,STATUS,PSTATS,[110]|[110]|
  DIALOG ADD,BITMAP,B1,0,0,0,0,#misc.bmp
  DIALOG ADD,BITMAP,B2,0,0,0,0,#dll.bmp
  DIALOG ADD,BITMAP,B3,0,0,0,0,#exe.bmp
  DIALOG ADD,BITMAP,B4,0,0,0,0,#taskh.bmp
  DIALOG ADD,BITMAP,B5,0,0,0,0,#task.bmp
  DIALOG REMOVE,B1
  DIALOG REMOVE,B2
  DIALOG REMOVE,B3
  DIALOG REMOVE,B4
  DIALOG REMOVE,B5
  GOSUB LOADAPPSTAB
  GOSUB LOADPROCTAB
  GOSUB LOADPERFTAB
  If @equal(%%Tab,2)
    DIALOG SET,TAB1,Processes
    %%STATUS = HIDE
    GOSUB STATUSAPPSTAB
    GOSUB STATUSPERFTAB
  ElsIf @equal(%%Tab,3)
    DIALOG SET,TAB1,Performance
    %%STATUS = HIDE
    GOSUB STATUSAPPSTAB
    GOSUB STATUSPROCTAB
  Else
    DIALOG SET,TAB1,Applications
    %%STATUS = HIDE
    GOSUB STATUSPROCTAB
    GOSUB STATUSPERFTAB
  End
  DIALOG SETPOS,APPTABLEGRP,49,23,352,280
  DIALOG SETPOS,APPSTABLE,49,23,352,280
  DIALOG SETPOS,PROCTABLEGRP,49,23,352,280
  DIALOG SETPOS,PROCTABLE,49,23,352,280
  List Create,1
  List Create,2
  List Create,3
  List Create,4
  List Create,5
  List Create,6
  Gosub LoadTasks
  List ASSIGN,PROCTABLE,4
  List Clear,4
  List Assign,6,4
  Gosub LoadProcs
  List ASSIGN,APPSTABLE,2
  List Clear,5
  List Assign,5,2
  DIALOG SHOW
  %%WinView = 1
  %%StatusLabel =

:EVENTLOOP
  wait event,0
  %E = @event()
  If %E
    Goto %E
  End
  Goto EventLoop

:TIMER
  %%Counter = @sum(%%Counter,1)
  If @Greater(%%Counter,%%Limit)
    %S = @regread(STATS,PerfStats\StatData,KERNEL\CPUUsage)
    Gosub COMPUTE
    If @not(@equal(%%Started,%S))
      Dialog Set,LEVEL1,%S
      Dialog Set,SCOPE3,%S
      Dialog Set,TEXT1,%S"%"
      %%Started = %S
      %%CpuUsage = "CPU Usage:  "%S"%"
    End
    %S = @regread(STATS,PerfStats\StatData,KERNEL\CPUUsage)
    Gosub COMPUTE
    If @not(@equal(%%StartedT,%S))
      Dialog Set,TTHREAD,%S
      %%StartedT = %S
    End
    If @not(@equal(@dlgtext(TPROCES),@count(PROCTABLE)))
      Dialog Set,TPROCES,@count(PROCTABLE)
      %%Processes = "Processes:  "@count(PROCTABLE)
    End
    If @not(@equal(@dlgtext(THANDLE),@count(APPSTABLE)))
      Dialog Set,THANDLE,@count(APPSTABLE)
    End
    %V = @binary(dword,32)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)
    %A = @LIB(kernel32,GlobalMemoryStatus,NIL:,@addr("%V"))
    %%dwLength = @val(@substr(%V,1,4))
    %%dwMemoryLoad = @val(@substr(%V,5,8))
    %%dwTotalPhys = @val(@substr(%V,9,12))
    %%dwAvailPhys = @val(@substr(%V,13,16))
    %%dwTotalPageFile = @val(@substr(%V,17,20))
    %%dwAvailPageFile = @val(@substr(%V,21,24))
    %%dwTotalVirtual = @val(@substr(%V,25,28))
    %%dwAvailVirtual = @val(@substr(%V,29,32))
    %%TotalPhysical = %%dwTotalPhys
    %%TotalPhysical = @fdiv(%%TotalPhysical,1024)
    %%TKB = %%TotalPhysical
    %%TotalPhysical = @sum(1,@name(@fdiv(%%TotalPhysical,1024)))
    %%AA = @fdiv(@sysinfo(freemem),1024)
    %%BB = @fdiv(%%AA,%%TotalPhysical)
    %%CC = @fmul(100,%%BB)
    If @not(@equal(%%CC),%%CCC)
      DIALOG SET,PT1,@fdiv(%%dwTotalPhys,1024)
      DIALOG SET,PT2,@fdiv(%%dwAvailPhys,1024)
      DIALOG SET,PT3,@fsub(@fdiv(%%dwTotalPhys,1024),@fdiv(%%dwAvailPhys,1024))
      DIALOG SET,TEXT2,@fsub(%%TKB,@sysinfo(freemem))"k"
      DIALOG SET,LEVEL2,@name(@fsub(100,%%CC))
      Dialog Set,SCOPE4,@name(@fsub(100,%%CC))
      %%CCC = %%CC
      %%MemUsage = "Memory Usage:  "@fsub(@fdiv(%%dwTotalPhys,1024),@fdiv(%%dwAvailPhys,1024))
    End
    If @not(@equal(@dlgtext(KT5),@fdiv(%%dwAvailPageFile,1024)))
      DIALOG SET,KT4,@fdiv(%%dwTotalPageFile,1024)
      DIALOG SET,KT5,@fdiv(%%dwAvailPageFile,1024)
      DIALOG SET,KT6,@fsub(@fdiv(%%dwTotalPageFile,1024),@fdiv(%%dwAvailPageFile,1024))
    End
    If @not(@dlgtext(APPCHECK))
      Gosub LoadProcs
      If @not(@equal(@text(2),@text(5)))
        %Z = @winexists(#vdstaskmanAGER)
        %A = @sendmsg(%Z,$0B,0,0)
        %Z = @winexists(~APPSTABLE)
        %A = @sendmsg(%Z,$0B,0,0)
        List Clear,APPSTABLE
        List ASSIGN,APPSTABLE,2
        %Z = @winexists(#vdstaskmanAGER)
        %A = @sendmsg(%Z,$0B,1,0)
        %Z = @winexists(~APPSTABLE)
        %A = @sendmsg(%Z,$0B,1,0)
        List Clear,5
        List Assign,5,2
      End
    End
    If @not(@dlgtext(PROCCHECK))
      Gosub LoadTasks
      If @not(@equal(@text(4),@text(6)))
        %Z = @winexists(#vdstaskmanAGER)
        %A = @sendmsg(%Z,$0B,0,0)
        %Z = @winexists(~PROCTABLE)
        %A = @sendmsg(%Z,$0B,0,0)
        List Clear,PROCTABLE
        List ASSIGN,PROCTABLE,4
        %Z = @winexists(#vdstaskmanAGER)
        %A = @sendmsg(%Z,$0B,1,0)
        %Z = @winexists(~PROCTABLE)
        %A = @sendmsg(%Z,$0B,1,0)
        List Clear,6
        List Assign,6,4
      End
    End
    If @not(@equal(%%StatusLabel,%%Processes@tab()%%CpuUsage@tab()%%MemUsage))
      DIALOG SET,PSTATS,%%Processes@tab()%%CpuUsage@tab()%%MemUsage
      %%StatusLabel = %%Processes@tab()%%CpuUsage@tab()%%MemUsage)
    End
    %%Counter = 0
  End
  If @equal(%%WinView,1)
    If @equal(@winpos(#vdstaskmanAGER,S),2)
      Window Hide,#vdstaskmanAGER
      DIALOG ADD,TASKICON,TASKICON1,#sysicon.ico,VDS TaskManager
      %%WinView = 0
    End
    If @equal(@winpos(#vdstaskmanAGER,S),1)
      %T = @winpos(#vdstaskmanAGER,T)
      %L = @winpos(#vdstaskmanAGER,L)
    End
  End
  If @winexists(#vdstaskmanAGERRCL)
    %%ReclaimOn = 1
    DIALOG DISABLE,RCLBTN
  End
  If %%ReclaimOn
    If @not(@winexists(#vdstaskmanAGERRCL))
      %%ReclaimOn =
      DIALOG ENABLE,RCLBTN
    End
  End
  Goto EventLoop

:CLOSE
  FreeLib kernel32
  %7 = @regread(STATS,PerfStats\StopStat,KERNEL\CPUUsage)
  %7 = @regread(STATS,PerfStats\StopStat,KERNEL\Threads)
  %T = @winpos(#vdstaskmanAGER,T)
  %L = @winpos(#vdstaskmanAGER,L)
  Inifile Open,@path(%0)%%FileName".ini"
  Inifile Write,Settings,T,%T
  Inifile Write,Settings,L,%L
  Inifile Write,Settings,TAB,%%Tab
  Exit

:TASKICON1CLICK
  Window Position,#vdstaskmanAGER,%T
  Window Normal,#vdstaskmanAGER
  Window Activate,#vdstaskmanAGER
  %%WinView = 1
  DIALOG REMOVE,TASKICON1
  goto Eventloop

:COMPUTE
  parse "%1;%2;%3;%4",%S
  %S = @sum(@sum(%1,@prod(256,%2)),@prod(65536,%3))
  Exit

:LoadProcs
  Option Fieldsep,|
  List Clear,1
  List Clear,2
  List TaskList,1,NI
  Repeat
    Option Fieldsep,|
    Parse "%%Path;%%ID",@item(1)
    If @equal(@ext(%%Path),exe)
      LIST ADD,2,@lower(@name(%%Path).@ext(%%Path))@tab()%%ID@tab()%%Path|#exe.bmp
    ElsIf @equal(@ext(%%Path),dll)
      LIST ADD,2,@lower(@name(%%Path).@ext(%%Path))@tab()%%ID@tab()%%Path|#dll.bmp
    Else
      LIST ADD,2,@lower(@name(%%Path).@ext(%%Path))@tab()%%ID@tab()%%Path|#misc.bmp
    End
    %%Null = @next(1)
  Until @null(@item(1))
  LIST SORT,2
  Exit

:LoadTasks
  Option Fieldsep,|
  List Clear,3
  List Clear,4
  List WinList,3,ICN
  Repeat
    Parse "%%ID;%%Class;%%Title",@item(3)
    If @null(%%Title)
      LIST ADD,4,%%Title@tab()%%Class@tab()%%ID|#taskh.bmp
    Else
      LIST ADD,4,%%Title@tab()%%Class@tab()%%ID|#task.bmp
    End
    %%Null = @next(3)
  Until @null(@item(3))
rem  LIST SORT,4
  Exit

:ApplicationsCLICK
  %%STATUS = HIDE
  GOSUB STATUSPROCTAB
  GOSUB STATUSPERFTAB
  %%STATUS = SHOW
  GOSUB STATUSAPPSTAB
  %%Tab = 1
  Goto EventLoop

:ProcessesCLICK
  %%STATUS = HIDE
  GOSUB STATUSAPPSTAB
  GOSUB STATUSPERFTAB
  %%STATUS = SHOW
  GOSUB STATUSPROCTAB
  %%Tab = 2
  Goto EventLoop

:PerformanceCLICK
  %%STATUS = HIDE
  GOSUB STATUSAPPSTAB
  GOSUB STATUSPROCTAB
  %%STATUS = SHOW
  GOSUB STATUSPERFTAB
  %%Tab = 3
  Goto EventLoop

:BTNNEWTASKBUTTON
  Run @shortname(%0) /T
  Goto EventLoop

:RUNNEWTASK
  If @winexists(#JFWRUNNEWTASK)
    Goto EventLoop
  End
  List Create,10
  List Loadfile,10,@path(%0)run.dat
  If @greater(@count(10),25)
    List Create,11
    List Seek,10,0
    Repeat
      List Add,11,@item(10)
      %%Null = @next(10)
    Until @null(@item(10))@equal(@index(10),24)
    List Clear,10
    List Assign,10,11
    List Clear,11
    List Close,11
  End
  DIALOG CREATE,JFW Run,-1,0,340,136,SMALLCAP,ONTOP,CLASS JFWRUNNEWTASK
  DIALOG ADD,STYLE,RSTYLE1,MS Sans Serif,8,,,
  DIALOG ADD,BITMAP,RBITMAP1,18,10,32,32,#run.ico
  DIALOG ADD,TEXT,RTEXT1,19,55,254,31,"Type the name of a program, folder, or document, and Windows will open it for you.",,RSTYLE1
  DIALOG ADD,TEXT,RTEXT2,64,10,,,Open:,,RSTYLE1
  DIALOG ADD,COMBO,RCOMBO1,60,54,275,21,,,RSTYLE1
  DIALOG ADD,BUTTON,RBTNOK,102,93,75,24,OK,,DEFAULT
  DIALOG ADD,BUTTON,RBTNCANCEL,102,174,75,24,Cancel
  DIALOG ADD,BUTTON,RBTNBROWSE,102,255,75,24,Browse...
  List Assign,RCOMBO1,10
  DIALOG SHOW
  :RUNLOOP
  WAIT EVENT
  %E = @event()
  If @equal(%E,RBTNOKBUTTON)
    Goto RBTNOKBUTTON
  End
  If @equal(%E,RBTNCANCELBUTTON)
    Goto EXITRUN
  End
  If @equal(%E,RBTNBROWSEBUTTON)
    Goto RBTNBROWSEBUTTON
  End
  If @equal(%E,CLOSE)
    Goto EXITRUN
  End
  If @equal(%E,TIMER)
    Goto RUNLOOP
  End
  Goto EXITRUN

:RBTNOKBUTTON
  If @dlgtext(RCOMBO1)
    %F = @dlgtext(RCOMBO1)
    If @greater(@count(RCOMBO1),0)
      List Seek,RCOMBO1,0
      List Insert,RCOMBO1,%F
    Else
      List Add,RCOMBO1,%F
    End
    REM Shell Open,%F
    Run @chr(34)%F@chr(34)
  End
  Goto EXITRUN

:RBTNBROWSEBUTTON
  %F = @filedlg("Executable file (*.exe)|*.exe|Batch file (*.bat)|*.bat|Command file (*.com)|*.com|All files (*.*)|*.*",Select file)
  If %F
    Dialog Set,RCOMBO1,%F
  End
  Goto RUNLOOP

:EXITRUN
  List Savefile,RCOMBO1,@path(%0)run.dat
  List Clear,10
  List Close,10
  Exit

:BTNENDTASKBUTTON
  If @item(APPSTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(APPSTABLE)
    DIALOG CREATE,%%ProgramName - Closing Task...,-1,0,240,86,SMALLCAP,NOSYS,ONTOP
    DIALOG ADD,TEXT,tCTEXT1,18,16,,,Attempting to close a task
    DIALOG ADD,PROGRESS,tCPROGRESS1,51,16,208,18,1,,SMOOTH
    DIALOG SELECT,1
    DIALOG SHOW
    Killtask %2
    List Create,8
    %%eCounter = 1
    Repeat
      DIALOG SELECT,1
      Wait "0.5"
      %%Null =
      List Clear,8
      List WinList,8,I
      %%Null = @match(8,%2)
      If %%Null
        %%Null =
      Else
        %%Null = Done
      End
      %%eCounter = @succ(%%eCounter)
      Dialog Set,tCPROGRESS1,%%eCounter
      If @equal(%%eCounter,100)
        Warn "Task did not close within a reasonable amount of time.  You may need to use CTRL+ALT+DEL to see if the task is available there to kill, or another program intended for hard killing tasks."
        %%Null = Done
      End
    Until @equal(%%Null,Done)
    List Close,8
    Dialog Close
    %E = @event()
  End
  DIALOG SELECT,0
  Goto Eventloop

:BTNSHOWBUTTON
  If @item(PROCTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(PROCTABLE)
    Window Normal,%3
    Window Activate,%3
  End
  Goto EventLoop

:BTNHIDEBUTTON
  If @item(PROCTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(PROCTABLE)
    Window Hide,%3
  End
  Goto EventLoop

:BTNMINBUTTON
  If @item(PROCTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(PROCTABLE)
    Window Iconize,%3
  End
  Goto EventLoop

:BTNMAXBUTTON
  If @item(PROCTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(PROCTABLE)
    Window Maximize,%3
  End
  Goto EventLoop

:BTNENDPROCBUTTON
  If @item(PROCTABLE)
    Option Fieldsep,@tab()
    Parse "%1;%2;%3", @item(PROCTABLE)
    DIALOG CREATE,%%ProgramName - Closing Task...,-1,0,240,86,SMALLCAP,NOSYS,ONTOP
    DIALOG ADD,TEXT,eCTEXT1,18,16,,,Attempting to close a task
    DIALOG ADD,PROGRESS,eCPROGRESS1,51,16,208,18,1,,SMOOTH
    DIALOG SELECT,1
    DIALOG SHOW
    Window Close,%3
    List Create,7
    %%eCounter = 1
    Repeat
      DIALOG SELECT,1
      Wait "0.5"
      %%Null =
      List Clear,7
      List WinList,7,I
      %%Null = @match(7,%3)
      If %%Null
        %%Null =
      Else
        %%Null = Done
      End
      %%eCounter = @succ(%%eCounter)
      Dialog Set,eCPROGRESS1,%%eCounter
      If @equal(%%eCounter,100)
        Warn "Task did not close within a reasonable amount of time.  You may need to use CTRL+ALT+DEL to see if the task is available there to kill, or another program intended for hard killing tasks."
        %%Null = Done
      End
    Until @equal(%%Null,Done)
    List Close,7
    Dialog Close
    %E = @event()
  End
  DIALOG SELECT,0
  Goto Eventloop

:RCLBTNBUTTON
  Run @shortname(%0) /R
  Goto Eventloop

:RECLNOW
  DIALOG CREATE,VDS Task Manager Reclaim,%T,%L,396,399,CLASS vdstaskmanAGERRCL
  LoadLib kernel32.dll
  %V = @binary(dword,32)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)
  %A = @LIB(kernel32,GlobalMemoryStatus,NIL:,@addr("%V"))
  %%dwTotalPhys = @val(@substr(%V,9,12))
  FreeLib kernel32
  %%TotalPhysical = %%dwTotalPhys
  %%TotalPhysical = @fdiv(%%TotalPhysical,1024)
  %%TotalPhysical = @fdiv(%%TotalPhysical,1024)
  %%TotalMem = @name(%%TotalPhysical)
  List Create,1
  List Create,2
  Repeat
    List Add,1,1OXOXOXOXOXOXOXOXOXOXOXOXOXOXOX0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0X0
    %%Null = @sum(%%Null,1)
  Until @equal(%%Null,1024)
  %%Null = 0
  Repeat
rem    Wait "0.1"
    %S = @div(@prod(%%Null,100),%%TotalMem)
    List Add,2,@text(1)
    %%Null = @sum(%%Null,1)
  Until @equal(%%Null,@sum(%%TotalMem,2))
  List Clear,1
  List Close,1
  List Clear,2
  List Close,2

  Exit

:ABTBTNBUTTON
  Run @shortname(%0) /A
  Goto Eventloop

:ABOUTBOX
  INFO Program Name:@tab()%%ProgramName@cr()Prog Version:@tab()%%ProgramVersion@cr()Program Date:@tab()%%ProgramDate@cr()Prog Author:@tab()%%Company@cr()Web Site URL:@tab()%%URL@cr()Email Info:@tab()%%Email@cr()Email Support:@tab()%%SupportEmail@cr()Copyright Info:@tab()%%CopyYear%%Company@cr()" "@cr()Registered to:@tab()%%RegdUser
  EXIT


REM   .:::::::::::|ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ|:::::::::::.
REM  :::::::::::::| ERROR BRANCH                     |:::::::::::::
REM   ·:::::::::::|__________________________________|:::::::::::·

:ErrorBranch
  RUN @shortname(%0)" /ER "@error(E)" "@error(N)" "%E
  FreeLib kernel32
  %7 = @regread(STATS,PerfStats\StopStat,KERNEL\CPUUsage)
  %7 = @regread(STATS,PerfStats\StopStat,KERNEL\Threads)
  STOP

  :ERRORDIALOG
    DIALOG CREATE,%%ProgramName Error,-1,0,450,293,NOSYS,ONTOP
    DIALOG ADD,STYLE,ERSTYLE4,Verdana,8,,,
    DIALOG ADD,STYLE,ERSTYLE3,Verdana,8,,WHITE,BLACK
    DIALOG ADD,STYLE,ERSTYLE2,Verdana,8,B,WHITE,BLACK
    DIALOG ADD,STYLE,ERSTYLE1,,,,WHITE,WHITE
    DIALOG ADD,TEXT,ERHEADERBACK,0,0,450,78,,,ERSTYLE1
    DIALOG ADD,PROGRESS,ERHEADERLINE,78,0,450,2,0
    DIALOG ADD,TEXT,ERHEADERTITLE,16,16,,,Program error notice,,ERSTYLE2
    DIALOG ADD,TEXT,ERHEADERTEXT,38,30,340,30,"The program encountered an error and is providing information you can send to the support department",,ERSTYLE3
    DIALOG ADD,BITMAP,ERBITMAP1,10,390,48,48,#error.bmp
    DIALOG ADD,TEXT,ERTEXT1,90,10,420,44,"In the edit box below there is some information regarding the error that has occured in the program.  If you wish, you may send this information to the support department"
    DIALOG ADD,EDIT,EREDIT1,150,10,420,98,,,MULTI,SCROLL,WRAP,ERSTYLE4
    DIALOG ADD,BUTTON,ERBUTTON4,260,374,65,24,Ok,,DEFAULT
    DIALOG SHOW
    LIST CREATE,1
    LIST Add,1,"Copy the following information and email it to the support"
    LIST Add,1,"department at:  "%%SupportEmail
    LIST Add,1,
    LIST Add,1,"Program Name:"@tab()%%ProgramName
    LIST Add,1,"Program Ver:"@tab()%%ProgramVersion
    LIST Add,1,"Program Date:"@tab()%%ProgramDate
    LIST Add,1,"Error Code:"@tab()%2
    LIST Add,1,"Line Number:"@tab()%3
    LIST Add,1,"Event Status:"@tab()%4
    If @equal(@null(@regread(LOCAL,SOFTWARE\Microsoft\Windows NT\CurrentVersion,CurrentVersion)))
      LIST ADD,1,"OS Name:"@tab()@regread(LOCAL,SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName)
      LIST ADD,1,"OS Version:"@tab()@regread(LOCAL,SOFTWARE\Microsoft\Windows NT\CurrentVersion,CurrentVersion)
      LIST ADD,1,"OS Build:"@tab()@regread(LOCAL,SOFTWARE\Microsoft\Windows NT\CurrentVersion,CurrentBuildNumber)
    Else
      LIST ADD,1,"OS Version:"@tab()@regread(LOCAL,Software\Microsoft\Windows\CurrentVersion,Version)
      LIST ADD,1,"OS Ver Num:"@tab()@regread(LOCAL,Software\Microsoft\Windows\CurrentVersion,VersionNumber)
    End
    LIST Add,1,"Free memory"@tab()@SYSINFO(FREEMEM)" Kb"
    LIST Add,1,"HD Free (c:\):"@tab()@volinfo(C,F)" Kb"
    DIALOG SET,EREDIT1,@text(1)
    LIST CLEAR,1
    LIST CLOSE,1
    WAIT EVENT
    EXIT
    STOP

:LOADAPPSTAB
  DIALOG ADD,CHECK,APPCHECK,29,23,200,,Lock application table from update
  DIALOG ADD,GROUP,APPTABLEGRP,1,1,1,1,,,STYLE0
  DIALOG ADD,TABLE,APPSTABLE,1,1,1,1,Task[180]|ID[60]|Path[600],,COLUMNSORT
  DIALOG ADD,BUTTON,BTNENDTASK,335,211,80,24,End Task
rem  DIALOG ADD,BUTTON,BTNSWITCH,335,211,80,24,Switch To
  DIALOG ADD,BUTTON,BTNNEWTASK,335,295,80,24,New Task...
  EXIT

:STATUSAPPSTAB
  DIALOG %%STATUS,APPCHECK
  DIALOG %%STATUS,APPTABLEGRP
  DIALOG %%STATUS,APPSTABLE
  DIALOG %%STATUS,BTNENDTASK
rem  DIALOG %%STATUS,BTNSWITCH
  DIALOG %%STATUS,BTNNEWTASK
  EXIT

:LOADPROCTAB
  DIALOG ADD,CHECK,PROCCHECK,29,23,200,,Lock process table from update
  DIALOG ADD,GROUP,PROCTABLEGRP,3,1,1,1,,,STYLE0
  DIALOG ADD,TABLE,PROCTABLE,3,1,1,1,Name[160]|WinClass[110]|WinID[60],,COLUMNSORT
  DIALOG ADD,BUTTON,BTNSHOW,335,23,64,24,Restore
  DIALOG ADD,BUTTON,BTNMAX,335,91,64,24,Maximize
  DIALOG ADD,BUTTON,BTNMIN,335,159,64,24,Minimize
  DIALOG ADD,BUTTON,BTNHIDE,335,227,64,24,Hide
  DIALOG ADD,BUTTON,BTNENDPROC,335,295,80,24,End Process
  EXIT

:STATUSPROCTAB
  DIALOG %%STATUS,PROCCHECK
  DIALOG %%STATUS,PROCTABLEGRP
  DIALOG %%STATUS,PROCTABLE
  DIALOG %%STATUS,BTNENDPROC
  DIALOG %%STATUS,BTNSHOW
  DIALOG %%STATUS,BTNHIDE
  DIALOG %%STATUS,BTNMIN
  DIALOG %%STATUS,BTNMAX
  EXIT

:LOADPERFTAB
  DIALOG ADD,GROUP,CPUUSEGRP,34,21,90,90,CPU Usage,,STYLE0
  DIALOG ADD,LINE,LINE1,53,29,72,62
  DIALOG ADD,TEXT,BACK1,54,30,69,60,TEXT3,,STYLE3
  DIALOG ADD,LEVEL,LEVEL1,59,43,43,35,0
  DIALOG ADD,TEXT,TEXT1,93,48,34,16,"0%",,STYLE1
  DIALOG ADD,GROUP,MEMUSEGRP,128,21,90,89,Mem Usage,,STYLE0
  DIALOG ADD,LINE,LINE2,147,29,72,62
  DIALOG ADD,TEXT,BACK2,148,30,69,60,TEXT3,,STYLE3
  DIALOG ADD,LEVEL,LEVEL2,153,43,43,35,0
  DIALOG ADD,TEXT,TEXT2,188,34,62,16,000000k,,STYLE2
  DIALOG ADD,GROUP,CPUHISTGRP,34,126,249,89,CPU Usage History,,STYLE0
  DIALOG ADD,LINE,LINE3,53,134,232,62
  DIALOG ADD,SCOPE,SCOPE3,54,135,230,60,0,,MEDIUM,STYLE1
  DIALOG ADD,GROUP,MEMHISTGRP,128,126,249,89,Memory Usage History,,STYLE0
  DIALOG ADD,LINE,LINE4,147,134,233,62
  DIALOG ADD,SCOPE,SCOPE4,148,135,231,60,0,,MEDIUM,STYLE1
  DIALOG ADD,GROUP,TOTALSGROUP,225,21,170,62,Totals,,STYLE0
  DIALOG ADD,TEXT,LHANDLE,240,28,,,Applications,,STYLE0
  DIALOG ADD,TEXT,THANDLE,240,155,,,0000,,STYLE0A
  DIALOG ADD,TEXT,LPROCES,255,28,,,Processes,,STYLE0
  DIALOG ADD,TEXT,TPROCES,255,155,,,0000,,STYLE0A
  DIALOG ADD,TEXT,LTHREAD,269,28,,,Threads,,STYLE0
  DIALOG ADD,TEXT,TTHREAD,269,155,,,0000,,STYLE0A
  DIALOG ADD,GROUP,COMMITGROUP,296,21,170,62,"Miscellaneous",,STYLE0
  DIALOG ADD,BUTTON,ABTBTN,322,32,64,24,About
  DIALOG ADD,BUTTON,RCLBTN,322,96,84,24,Reclaim Mem
REM  DIALOG ADD,TEXT,TTOTAL,311,143,,,000000,,STYLE0A
REM  DIALOG ADD,TEXT,LLIMIT,326,28,,,Limit,,STYLE0
REM  DIALOG ADD,TEXT,TLIMIT,326,143,,,000000,,STYLE0A
REM  DIALOG ADD,TEXT,LPEAK,341,28,,,Peak,,STYLE0
REM  DIALOG ADD,TEXT,TPEAK,341,143,,,000000,,STYLE0A
  DIALOG ADD,GROUP,PHYSGROUP,225,204,171,62,"Physical Memory (k)",,STYLE0
  DIALOG ADD,TEXT,PL1,240,211,,,Total,,STYLE0
  DIALOG ADD,TEXT,PT1,240,338,,,0000,,STYLE0A
  DIALOG ADD,TEXT,PL2,255,211,,,Available,,STYLE0
  DIALOG ADD,TEXT,PT2,255,338,,,0000,,STYLE0A
  DIALOG ADD,TEXT,PL3,269,211,,,Used,,STYLE0
  DIALOG ADD,TEXT,PT3,269,338,,,0000,,STYLE0A
  DIALOG ADD,GROUP,KERNGROUP,296,204,171,62,"Swap File (k)",,STYLE0
  DIALOG ADD,TEXT,KL4,311,211,,,Total,,STYLE0
  DIALOG ADD,TEXT,KT4,311,326,,,000000,,STYLE0A
  DIALOG ADD,TEXT,KL5,326,211,,,Available,,STYLE0
  DIALOG ADD,TEXT,KT5,326,326,,,000000,,STYLE0A
  DIALOG ADD,TEXT,KL6,341,211,,,Used,,STYLE0
  DIALOG ADD,TEXT,KT6,341,326,,,000000,,STYLE0A
  EXIT

:STATUSPERFTAB
  DIALOG %%STATUS,CPUUSEGRP
  DIALOG %%STATUS,MEMUSEGRP
  DIALOG %%STATUS,CPUHISTGRP
  DIALOG %%STATUS,MEMHISTGRP
  DIALOG %%STATUS,TOTALSGROUP
  DIALOG %%STATUS,COMMITGROUP
  DIALOG %%STATUS,PHYSGROUP
  DIALOG %%STATUS,KERNGROUP
  EXIT

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon May 03, 2004 8:03 am    Post subject: Reply with quote

Funny thing. I was just getting ready to release a new DLL handling, among other things, memory
information. Plugs into PSAPI...

Look for DiskNMem.DLL Wink

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Mon May 03, 2004 8:12 am    Post subject: Reply with quote

Thanks Dr. Dread, for your predicting vision... Wink
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon May 03, 2004 1:46 pm    Post subject: Reply with quote

I think coincidence ruled here more than predicting vision Wink

Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon May 03, 2004 9:10 pm    Post subject: Reply with quote

Nice code. Thanks Garrett. Very Happy Thumbs Up
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Wed May 19, 2004 5:09 pm    Post subject: Reply with quote

I was thinking... how about creating a program that scans your computer
for running programs/services, and looks in an external database
somewhere on the internet if the program should be considered as
spyware. If it's identified as spyware, we'll let our program shut it down
immediately.

We can keep the database up to date by letting users add programs that
they consider as spyware to the database (via the program itself ofcourse)

Regards,
Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed May 19, 2004 5:58 pm    Post subject: Reply with quote

Maybe there already is an open-source database which such things in it which we can use?
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Wed May 19, 2004 6:43 pm    Post subject: Reply with quote

http://www.pestpatrol.com/Search/query.asp Smile

Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Sat May 22, 2004 3:40 pm    Post subject: Reply with quote

Program error notice:

Program Name: VDS Task Manager
Program Ver: 1.0.0.1
Program Date: 27 April, 2003
Error Code: 25
Line Number: 273
Event Status: TIMER
OS Name: Microsoft Windows XP
OS Version: 5.1
OS Build: 2600
Free memory 270452 Kb
HD Free (c:\): 11784456 Kb
Back to top
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat May 22, 2004 6:31 pm    Post subject: Reply with quote

If the above error is in reference to the source code I posted above, I may
have neglected to mention that it works only Win9x systems only and not
on NT based systems. This is due to code which calls for a registry entry
that does exists in the 9x systems but is not available in the NT systems.
The entry is for getting the current CPU percentage.

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Zhoul
Newbie


Joined: 09 Jan 2006
Posts: 1
Location: 127.0.0.1

PostPosted: Mon Jan 09, 2006 11:40 am    Post subject: Kill.bat Reply with quote

Hey there folks. I stumbled upon this age old thread while looking for a tasklist.exe and taskkill.exe to suppliment a very extensive .bat file I've written, for WinXP/2003 systems, which 'commands' tasklist.exe and taskkill.exe in a rather sleek, easy to use, and very automated fashion.

While this isn't a VDS script: It could be commanded by one and it's output parsed for UI representation.

You can find a pretty good write-up on this .bat file here:
http://forum.cheatengine.org/viewtopic.php?t=4803&start=0&postdays=0&postorder=asc&highlight=

I'll copy/paste the write-up you can find at that link, but there are also supplimental screenshots that can be found there, which won't be posted here. What I will do here, however, is paste in the current 'code' of the .bat file, to this post, at the very bottom.

Have fun!

- Zhoul

Zhoul wrote:

This one is pretty much for the console/DOS junkies, the unix/linux users forced to work on windows PC's, or the large-network/home-network folks. Kill, is actually derived from the unix/linux command with the same name.

Ever wanted an easier, faster, smarter, tasklist.exe and taskkill.exe that didn't require such extensive command lines? That remembered which PC you're currently 'working with', or a way to at least list processes, before killing them, en masse? How about a simple way to kill both PID's and image names, without having to run taskkill twice or thrice? If you answered no to the entire line of questioning, go ahead and click 'back', as the rest of this will bore you to tears Laughing

Kill.bat ...

With a name as omnious, as shady and down-right scarry soundin', it's really not as 'bad' as it would appear Cool While it does pack a serious punch, it's a very console/carple-tunnel friendly tool.

It boasts a wide range of user customisation features, designed to fit like a glove in any network / admin / technical / home situation.

Why is it spiffy?
- Much quicker then using tlist/tkill individually.
- When you go to kill something(s), you get a list of what will be killed followed by a confirmation. (as using taskkill.exe without the help of this .bat will simply kill the process(es) without confirmation, which can be *bad* when using wildcards)
- Ability to 'remember' the last used User/Password/Domain/Computer Name for the specific shell instance. Does not save this information to file, for security purposes. Option to disable the feature entirely.
- Your choice of Command Line, Last Used, or Pre-Set User/Pass/Domain/PC. (Cmd Line Arg > Last Used > Pre-Set)
- Displays the tasklist command it used to list and the taskkill command it will use, as it asks for confirmation. (Confirmation can be disabled via command line switch or in-batch-file, user config option)
- Great for dual PC setups, especially when hackin' and crackin' a game that could lock up, disabling use of task manager (but easily killable, remotely, with your 2nd box).
- Looping Tasklister, via an undocumented (until this post) command line switch. Kill -L (which doubles as a 'boss key/screen' *wink*)
- True Story: I used to use this to remotely kill my roommates multiple pr0n downloads, as he ate away at my ping times, which were important for online gaming Twisted Evil

Installation/Usage:
- First, it's a .bat file. I could be a terrorist. There could be a WMD planted inside the batch file that could destroy your entire city. George W. Bush Jr. could actually be a smart man. While all these things are far from likely, I recommend looking at the file in notepad, if anything, to set your situation-specific options.
- Rename it to <whateveryouwant>.bat and place it in your path. Recommended Location: C:\Windows\System32 ( or %windir%\System32 )
- Load up a DOS prompt to use it. (Start > Run > cmd). Don't double click it and expect it to stay up long, as running it without arguments simply lists processes, so the window would appear for a brief moment then disappear. Again: For console junkies =) Not you clickedy clackers with your fancy mice and trackballs that usually impede preformance.
- Kill /? for help or examples

This batch file has 3 dependancies (which all come with XP/2003)
%windir%\system32\Tasklist.exe
%windir%\system32\Taskkill.exe
System Service: Event Log (tasklist and taskkill will not run without it)

Kill.bat can still list/kill processes on remote 98/2000 machines, it just won't run in their shell's, as tasklist and taskkill are features of XP/2003.

Each screenshot depicts the usage of an individual command, even though it may appear that a lot was done. (Actually, a lot was done, by the thing that should be doing it. Your PC).

I'll let kill /? and screenshots do the rest of the talkin'.


C:\Kill.bat /?

==================
Shocked Shocked Shocked Kill.Bat Shocked Shocked Shocked
==================

Syntax:
"Kill [-s [System]] [-u [Username]] [-p [Password] [[PID] || [Image Name]]"
"Kill -reset" (This will reset the user/pass/domain/pc to your defaults.)


Example: Kill

This would simply run tasklist.exe and display the results, using More.exe (incase task list is longer then window buffer - *Note* Feature is disabled by default. It got annoying imho, but I'll leave it up to you to decide.).


Example: Kill 989

This would kill the local process with PID 989.


Example: Kill iexpl

This would kill any process with an ImageName starting with iexpl
(first column listed in tasklist, i.e. iexplore.exe)

Such as: iexplore , iexplorer, iexplblahblahblah, iexplore.exe

This would NOT affect a process named prqiexplore.exe, as the string search will match "Starts with or Equals" and not "Contains or Equals"
If you wanted to kill prqiexplore.exe and iexplore.exe, you could . . .
kill *iexpl*

Example: Kill 989 iexpl 1000 badthing

This would kill the local process with PID 989, any ImageName that starts with iexpl, PID 1000, any ImageName that starts with badthing. Yep, you can take out multiple processess in the same kill line.


Example: Kill -s RemotePC

This would execute a tasklist on the RemotePC, using your current credentials.


Example: Kill \\RemotePC
Same as previous.


Example: Kill -s RemotePC -u RemotePC\Administrator -p RemotePCPassword
Or: Kill \\RemotePC -u RemotePC\Administrator -p RemotePCPassword

If the locally logged in user is not an Administrator of RemotePC, you will
have to specify a user and password.
Remember: If you just specify a Username and not a server, it will assume you mean a user on the local PC.
User can be: [user] or [domain]\[user] or [user]@[domain]
I.E. Zhoul ZhoulsPC\Zhoul Zhoul@ZhoulsPC


Example: Kill -s RemotePC -u RemotePC\Administrator -p RemotePCPassword 500

Kills PID 500 on RemotePC, using specified credentials.


Example: Kill -s RemotePC iexpl 500 calc

Kills ImageName starting with iexpl, PID 500, ImageName starting with calc, on the RemotePC using your current credentials.

There are a lot more command line options, that are described in the .bat file itself, right next to the user configurable option. Lastly, don't have too much fun Cool
- Z



The "Code" (if you can call it that Cool )
Code:

@echo off

rem For user options, search for text ChangeMe!

rem This batch file has 3 dependancies (which all come with XP/2003)
rem %windir%\system32\Tasklist.exe
rem %windir%\system32\Taskkill.exe
rem System Service: Event Log (tasklist and taskkill will not run without it)
rem Kill.bat can still list/kill processes on a remote 2000 machine, it just can't
rem run in a 2000 shell.

title Kill.bat


If NOT exist "%Windir%\System32\tasklist.exe" (
   echo Tasklist.exe not found in %windir%\system32\...
   echo Kill.bat was designed for use on Windows XP/2003...
   echo Exiting...
   goto end
)

If NOT exist "%Windir%\System32\taskkill.exe" (
   echo Taskkill.exe not found in %windir%\system32\...
   echo Kill.bat was designed for use on Windows XP/2003...
   echo Exiting...
   goto end
)


rem These are declerations (don't touch).  Look a bit further down for user config changes.
set rsys=
set rsysPrefix=
set rusr=
set rpwd=
set rpwdPrefix=
set UseRSysInUsername=
set rusrPrefix1=
set rusrPrefix2=
set UseSvc=
set FilterType=
set DefaultFilter=
set ShowCmd=
set DefPrefix=
set DefSuffix=
set UsePre=
set UseSuf=
set LoopKill=
set ListOnly=
set KillCurTime=%Time::=-%
set KillCurTime=%KillCurTime:.=-%


If "%1" == "/?" goto Help
If "%1" == "-?" goto Help
If "%1" == "--?" goto Help
If "%1" == "?" goto Help
If /I "%1" == "help" goto Help
If /I "%1" == "RESET" goto Reset
If /I "%1" == "-RESET" goto Reset


rem Environment Options (touch these as you wish)
rem -----------------------------------------------------------------------------------------------
rem (ChangeMe!) - Automatic login
rem Set the below, to automatically use Sys/Usr/Pwd options.
rem CAN be over-ridden by command line *and* by Use Previous, if enabled.
rem i.e. If I wanted the user name to default to Administrator
rem I would change 'set autoUsr='  to read 'autoUsr=Administrator'
rem Default: (autoSys=) , (autoUsr=) , (autoPwd=)
set autoSys=
set autoUsr=
set autoPwd=

rem (ChangeMe!) - Use Remote System Name in Username.
rem This is for situations where your network account isn't a domain
rem admin, but you know the local admin user/password.
rem Setting UseRSysInUsername=1 will prefix the username
rem with <CurrentRemotePCName>\
rem i.e. 
rem If the remote computer name is ZhoulsPC
rem If the remote username is Zhoul
rem It will change the remote username to ZhoulsPC\Zhoul
rem You can even set the autoUsr feature above, to Administrator
rem and the autoPwd feature to the local admin password, for prompt free task listing/killing.
rem Default: (UseRSysInUsername=0)
set UseRSysInUsername=0

rem (ChangeMe!) *New Feature* - Show Command
rem Set ShowCmd=1 if you would like to show the command(s) used during execution.
rem Set ShowCmd=0 if you wish to suppress this information from visual output.
rem I.E.
rem If this option were enabled and you typed 'Kill 360' , you would
rem get this as an extra output line.
rem Command  : taskkill /pid 360 /f /t
rem *Note* - Does not show the /p <password> portion of the command.
rem Default: (ShowCmd=1)
set ShowCmd=1



rem (ChangeMe!) - Temp Directory/File (Default=Auto-Detect)
rem One piece of this process uses an output file to dump the process list to.
rem By Default: It is set to detect %temp%, then use a file called tasklist.txt
rem *Update* - Changed to 'Tasklist-Current Time-%Random%.txt
rem I.E.  Tasklist-13-02-01-53-23456.txt
rem This change was made so multiple instances of kill.bat could run without error.
rem If %temp% doesn't exist, it uses the current directory.
rem This file is deleted right after use.
rem Default: (outfile="%temp%\tasklist-%KillCurTime%-%Random%.txt")
If "%temp%" == "" set temp=.\
set outfile="%temp%\tasklist-%KillCurTime%-%Random%.txt"



rem (ChangeMe!) - Remember System/Username/Password (for session).
rem If you would like to use the 'previous' system/user/password, set
rem this to 1.  I.E. if you open a DOS window and kill \\RemotePC,
rem the next time you type kill , It will remember you are 'using' RemotePC.
rem These settings will override the Auto settings above, and can be reset
rem via command line by using the -reset switch (kill -reset).
rem These settings can be over-ridden/over-written by command line options.
rem *NOTE* These settings are session based, therefore they *will not*
rem carry over between shell instances / two separate DOS windows.
rem Default: (UsePrevious=1)
set UsePrevious=1



rem (ChangeMe!) - Default Filter Prefix/Suffix
rem Here, you choose how kill.bat will handle image names (or shall  we say, non-PID's)
rem The prefix and suffix are applied during the filter process in tasklist.
rem Example: If both were set to * , then 'kill blah' would result in killing *blah*
rem To put it another way, It would kill any process with blah in any part of the name.
rem Setting both the prefix and suffix to nothing would result in having to use very
rem specific image names.
rem Default settings look for things that begin with the letters you type.
rem Example: kill expl    would kill explorer.exe but not iexplore.exe
rem The prefix and suffix are *not* applied when working with a PID. (that would be bad I think...)
rem Default: (DefPrefix=) , (DefSuffix=*)
set DefPrefix=
set DefSuffix=*


rem (ChangeMe!) - Default Filter (No Description)
rem Default: (DefaultFilter=IMAGENAME eq)
set DefaultFilter=IMAGENAME eq


rem (ChangeMe!)
rem Set NoConfirm=1 if you do not want kill.bat to confirm your kill commands before execution.
rem You can also use the /y switch to auto-confirm.
set NoConfirm=0



rem (ChangeMe!)
rem I can't take it NO MORE!
rem set NoMore=1 if you dislike the "more" program, chopping up your output.
rem set Nomore=0 if you are in a terminal window that does not allow scrolling.
rem Kill.bat can still be piped to more, reguardless...  (i.e. kill|more)
rem Default(NoMore=1)
set NoMore=1


rem REMEMBER: Command Line overrides Previous and Auto
rem REMEMBER: Previous overrides Auto (if enabled)
rem REMEMBER: Auto overrides none of the above.
rem You can also use the -reset switch, to reset the "Previous" override.
rem I.E.   Kill -reset
rem ...will set all the previous variables to nothing, letting your default system/user/pass take effect.
rem The -reset switch is completely useless if you do not have UsePrevious set to 1, above.
rem Why? Because the previous variables only get set IF UsePrevious is 'enabled'.
rem -----------------------------------------------------------------------------------------------


:ActivateAuto
rem -----------------------------------------------------------------------------------------------
  If DEFINED autoSys set rsys=%autoSys%
  If DEFINED autoUsr set rusr=%autoUsr%
  If DEFINED autoPwd set rpwd=%autoPwd%
rem -----------------------------------------------------------------------------------------------


:ActivateUsePrev
rem -----------------------------------------------------------------------------------------------

If "%UsePrevious%" == "1" (
  If DEFINED prevSys set rsys=%prevSys%
  If DEFINED prevUsr set rusr=%prevUsr%
  If DEFINED prevPwd set rpwd=%prevPwd%
)
rem -----------------------------------------------------------------------------------------------


:ParseArgs
rem -----------------------------------------------------------------------------------------------

set parseArg=%1
set parseArg=%parseArg:~0,2%

If /I "%parseArg%" == "\\" goto RSys2
If /I "%1" == "-r" goto RSys
If /I "%1" == "-s" goto RSys
If /I "%1" == "/r" goto RSys
If /I "%1" == "/s" goto RSys

If /I "%1" == "-u" goto RUsr
If /I "%1" == "/u" goto RUsr

If /I "%1" == "-p" goto RPwd
If /I "%1" == "/p" goto RPwd

If /I "%1" == "-y" goto NoConf
If /I "%1" == "/y" goto NoConf

If /I "%1" == "-list" goto ListOnly
If /I "%1" == "/list" goto ListOnly

If /I "%1" == "-n" goto ListOnly
If /I "%1" == "/n" goto ListOnly

If /I "%1" == "-l" goto SetLoopKill
If /I "%1" == "/l" goto SetLoopKill


If /I "%1" == "/svc" goto SvcEnum

If "%rsys%" == "" (
set rsys=
set rusr=
set rpwd=
)
if DEFINED rsys set rsysPrefix= /S
if DEFINED rpwd set rpwdPrefix= /P
If DEFINED rusr (set rusrPrefix1= /U ) else (goto ParseArgs2)
If NOT DEFINED UseRSysInUsername goto ParseArgs2
If NOT "%UseRSysInUsername%" == "1"  goto ParseArgs2
If NOT DEFINED rsys goto ParseArgs2
echo %rusr%|find "\"|rem
if "%errorlevel%" == "0" goto ParseArgs2
echo %rusr%|find "@"|rem
if "%errorlevel%" == "0" goto ParseArgs2
set rusrPrefix2=%rsys:~2%\


:ParseArgs2

rem Dos box title handling...
set Titletmp=Kill.bat
If "%rSys%" == "" (
   set Titletmp=%Titletmp% -- System: %computername%
) else (
   set Titletmp=%Titletmp% -- System: %rsys%
   prompt [System: %rsys%] - $p$g
)
If "%rUsr%" == "" (
   set Titletmp=%Titletmp% -- User: %Username% [Default]
) else (
   set Titletmp=%Titletmp% -- User: %rusrPrefix2%%rUsr%
)
If "%rPwd%" == "" (
   set Titletmp=%Titletmp% -- Password: [Default]
) else (
   set Titletmp=%Titletmp% -- Password: [User Specified]
)
Title %Titletmp%

If "%1" == "" (goto List) else (goto GoFigure)

:RSys
rem -- Remote System --
SHIFT
:RSys2
set rsys=%1
If "%rsys%" == "" (
        echo You specified the -r or -s option, but failed to specify the remote system there after.
   goto end
)
set rsystmp=%rsys:~0,2%

If NOT "%rsystmp%"  == "\\" set rsys=\\%rsys%

echo Remote System [ %rsys% ] accepted from command line...
SHIFT
goto ParseArgs


:RUsr
rem -- Remote Username --
SHIFT
set rusr=%1
set rusr=%rusr: =%
If "%rusr%" == "" (
   echo  You specified the -u option, but failed to specify the remote username there after.
   goto end
)
echo Remote Username [%rusrPrefix2%%rusr%] accepted from command line...
SHIFT
goto ParseArgs


:RPwd
rem -- Remote Password --
SHIFT
set rpwd=%1
If "%rpwd%" == "" (
   echo You specified the -p option, but failed to specify a password there after.
   goto end
)
echo Remote Password accepted from command line...
SHIFT
goto ParseArgs

:SvcEnum
rem -- Use /svc switch --
set UseSvc= /svc
SHIFT
goto ParseArgs

:NoConf
rem -- No Confirmation --
set NoConfirm=2
SHIFT
goto ParseArgs

:ListOnly
rem -- Auto-Answer No to process kill confirm question (Don't ask, just list) --
set ListOnly=1
SHIFT
goto ParseArgs

:SetLoopKill
rem -- Loop Killing --
set LoopKill=1
set LoopKillCount=20
set CurLoopCount=20
SHIFT
goto ParseArgs


rem -----------------------------------------------------------------------------------------------


:EnvVar2
rem Environment Variables 2
rem -----------------------------------------------------------------------------------------------


If "%1" == "" (goto List) else (goto GoFigure)

rem -----------------------------------------------------------------------------------------------




:GoFigure
rem -----------------------------------------------------------------------------------------------
set CurArg=%1
SHIFT

If "%CurArg%" == "" goto End

echo.

If /I "%CurArg%" == "/pid" (
   set FilterType=PID eq
   set UsePre=
   set UseSuf=
   SHIFT
   set CurArg=%1
   goto Proc
)

If /I "%CurArg%" == "-pid" (
   set FilterType=PID eq
   set UsePre=
   set UseSuf=
   SHIFT
   set CurArg=%1
   goto Proc
)

If /I "%CurArg%" == "/im" (
   set FilterType=IMAGENAME eq
   set UsePre=%DefPrefix%
   set UseSuf=%DefSuffix%
   SHIFT
   set CurArg=%1
   goto Proc
)

If /I "%CurArg%" == "-im" (
   set FilterType=IMAGENAME eq
   set UsePre=%DefPrefix%
   set UseSuf=%DefSuffix%
   SHIFT
   set CurArg=%1
   goto Proc
)


set FilterType=%DefaultFilter%
set UsePre=%DefPrefix%
set UseSuf=%DefSuffix%

If %CurArg% geq 0 (
        If %CurArg% leq 9999 (
      set FilterType=PID eq
      set UsePre=
      set UseSuf=
   )
)

goto Proc


rem -----------------------------------------------------------------------------------------------/



:Proc
rem -----------------------------------------------------------------------------------------------\

echo.
echo /----------------------------------------------------------------------\
If "%rsys%" == "" (
echo System   : %computername% [default]
set rusr=
set rpwd=
) else (
echo System   : %rsys%
)

If "%rusr%" == "" (
echo User     : %userdomain%\%username% [default]
) else (
echo User     : %rusrPrefix2%%rusr%
)

If "%rpwd%" == "" (
echo Password : [default]
) else (
echo Password : [specified]
)

If "%ShowCmd%" == "1" (
   echo Command  : tasklist%UseSvc%%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr% /FI "%FilterType% %UsePre%%CurArg%%UseSuf%"
)
echo ------------------------------------------------------------------------
tasklist%UseSvc%%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr%%rpwdPrefix%%rpwd% /FI "%FilterType% %UsePre%%CurArg%%UseSuf%" >%outfile%
If NOT "%NoMore%" == "1" (more /p /e /s /T0 %outfile%) else (type %outfile%)
find /c "PID" %outfile%|rem
If "%errorlevel%" == "1" (
   echo.
   goto GoFigure
)
del %outfile%
echo.
echo.
if "%ListOnly%" == "1" (
   goto GoFigure
)
echo Press [Enter] to kill the above task(s), or type 'n' [Enter] to abort.
If "%NoConfirm%" == "1" (
   echo Auto-Confirm - Reason:  Kill.bat setting.
   goto ExecKill
)
If "%NoConfirm%" == "2" (
   echo Auto-Confirm - Reason: Command line option /y.
   goto ExecKill
)
set Continue=
set /p Continue=
set ContinuePart=%Continue:~0,1%
If /I "%ContinuePart%"=="n" (
   echo.
   echo User aborted process kill command.
   goto GoFigure
)
If /I "%ContinuePart%"=="r" (
   goto Proc
)

:ExecKill
echo.
If "%ShowCmd%" == "1" (
   echo Command: taskkill%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr% /FI "%FilterType% %UsePre%%CurArg%%UseSuf%" /f /t
)
taskkill%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr%%rpwdPrefix%%rpwd% /FI "%FilterType% %UsePre%%CurArg%%UseSuf%" /f /t >%outfile%
If NOT "%NoMore%" == "1" (more /p /e /s /T0 %outfile%) else (type %outfile%)
del %outfile%
echo.
If /I NOT "%LoopKill%" == "1" goto GoFigure
If %CurLoopCount% leq 1 (
   echo Loop kill complete.
   set CurLoopCount=%LoopKillCount%
   goto GoFigure
)
echo Looping kill command %CurLoopCount% more times.
set /a CurLoopCount=%CurLoopCount%-1
goto ExecKill

rem -----------------------------------------------------------------------------------------------/




:List
rem -----------------------------------------------------------------------------------------------\

echo.
echo /----------------------------------------------------------------------\
If "%rsys%" == "" (
   echo System   : %computername% [default]
) else (
   echo System   : %rsys%
)

If "%rusr%" == "" (
   echo User     : %userdomain%\%username% [default]
) else (
   echo User     : %rusrPrefix2%%rusr%
)

If "%rpwd%" == "" (
   echo Password : [default]
) else (
   echo Password : [specified]
)

If "%ShowCmd%" == "1" (
   echo Command  : tasklist%UseSvc%%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr%
)

echo ------------------------------------------------------------------------
tasklist%UseSvc%%rsysPrefix%%rsys%%rusrPrefix1%%rusrPrefix2%%rusr%%rpwdPrefix%%rpwd%>%outfile%
If NOT "%NoMore%" == "1" (more /p /e /s /T0 %outfile%) else (type %outfile%)
find /c "PID" %outfile%|rem
del %outfile%
If /I "%LoopKill%" == "1" (
   echo.
   echo Looping in 4 seconds... Press CTRL+C to exit.
   ping 127.0.0.1|rem
   goto List
)

goto End
rem -----------------------------------------------------------------------------------------------


:Help
rem -----------------------------------------------------------------------------------------------
echo.
echo.
echo ================================================================================
echo                              Kill.bat - Designed by Zhoul
echo ================================================================================
echo.
echo Syntax:
echo   "Kill [-s [System]] [-u [Username]] [-p [Password] [[PID] || [Image Name]]"
echo   "Kill -reset" (Only use this option if you have enabled UsePrevious)
echo.
echo.
echo Example: Kill
echo.
echo   This would simply run tasklist.exe and display the results, using More (incase
echo   task list is longer then window buffer).
echo.
echo.
echo Example: Kill 989
echo.
echo   This would kill the local process with PID 989.
echo.
echo.
echo Example: Kill iexpl
echo.
echo   This would kill any process with an ImageName starting with iexpl
echo   (first column listed in tasklist, i.e. iexplore.exe)
echo.   
echo   Such as: iexplore , iexplorer, iexplblahblahblah, iexplore.exe
echo.
echo   This would NOT affect a process named prqiexplore.exe, as the string search
echo   will match "Starts with or Equals" and not "Contains or Equals"
echo   If you wanted to kill prqiexplore.exe and iexplore.exe, you could . . . 
echo   kill *iexpl*
echo.
echo ================================================================================
pause
echo ================================================================================
echo.
echo Example: Kill 989 iexpl 1000 badthing
echo.
echo   This would kill the local process with PID 989, any ImageName that starts with
echo   iexpl, PID 1000, any ImageName that starts with badthing.  Yep, you can take
echo   out multiple processess in the same kill line.
echo.
echo.
echo Example: Kill -s RemotePC
echo.
echo   This would execute a tasklist on the RemotePC, using your current credentials.
echo.
echo Example: Kill \\RemotePC
echo   Same as previous.
echo.
echo.
echo Example: Kill -s RemotePC -u RemotePC\Administrator -p RemotePCPassword
echo      Or: Kill \\RemotePC -u RemotePC\Administrator -p RemotePCPassword
echo.
echo   If the locally logged in user is not an Administrator of RemotePC, you will
echo   have to specify a user and password.
echo   Remember: If you just specify a Username and not a server before it, it will
echo   assume you mean a user on the local PC.
echo   User can be:  [user]      or     [domain]\[user]     or   [user]@[domain]
echo   I.E.           Zhoul              ZhoulsPC\Zhoul           Zhoul@ZhoulsPC
echo.
echo.
echo Example: Kill -s RemotePC -u RemotePC\Administrator -p RemotePCPassword 500
echo.
echo   Kills PID 500 on RemotePC, using specified credentials.
echo.
echo.
echo Example: Kill -s RemotePC iexpl 500 calc
echo.
echo   Kills ImageName starting with iexpl, PID 500, ImageName starting with calc, on
echo   the RemotePC using your current credentials.
echo.
echo ================================================================================
pause
goto End
rem -----------------------------------------------------------------------------------------------



:Reset
rem -----------------------------------------------------------------------------------------------
echo.
echo Resetting previously used System/User/Pass variables to defaults.
set prevSys=
set prevUsr=
set prevPwd=
set rsys=
set rusr=
set rusrPrefix=
set rpwd=
set autoSys=
set autoUsr=
set autoPwd=
set NoMore=
prompt
Title Kill.bat - Reset Previous System/User/Pass Complete
echo.
goto END
rem -----------------------------------------------------------------------------------------------



:End
rem -----------------------------------------------------------------------------------------------
If NOT "%UsePrevious%" == "1" goto ABSEnd
set prevSys=%rsys%
set prevUsr=%rusr%
set prevPwd=%rpwd%

:ABSEnd
set rsys=
set rusr=
set rpwd=
set autoSys=
set autoUsr=
set autoPwd=
set NoMore=
set UseSvc=
set ContinuePart=
set ShowCmd=
set DefPrefix=
set DefSuffix=
set DefaultFilter=
set FilterType=
set OutFile=
set Titletmp=
set UsePre=
set UseSuf=
set NoConfirm=
set ListOnly=
set ParseArg=
set UsePrevious=
set ArgPart=
set LoopKill=
set rsystmp=
set UseRSysInUsername=
set rusrPrefix1=
set rusrPrefix2=
set rpwdPrefix=
set rsysPrefix=
set LoopKillCount=
set LoopCurCount=
set KillCurTime=
rem -----------------------------------------------------------------------------------------------



Kill - v1.8.zip
 Description:

Download
 Filename:  Kill - v1.8.zip
 Filesize:  6.48 KB
 Downloaded:  1798 Time(s)

Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group