OT: why can't I use "tasklist" in the Windows XP Cmd window?

Mike Bonner bonnmike at gmail.com
Wed May 18 17:39:13 EDT 2011


I can't test with win xp, but you might put the following into a .vbs file.

*Set WshShell = WScript.CreateObject ("WScript.Shell")*
*Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from
Win32_Process")*
*
*
*For Each objProcess in colProcessList*
*If objProcess.name = "firefox.exe" then*
*vFound = True*
*End if*
*Next*
*If vFound = True then*
*WshShell.AppActivate "Firefox"*
*Else*
*WshShell.Run "Firefox.exe"*
*End If *

In my example, it will check for firefox, if its running it will focus on
it, if not it will start a new instance.  To use it, do a shell call.

get shell("myScript.vbs")

I'm sure it could be easily modified so you could pass it the program to
find as a parameter, but if its always the same hard coded should be fine.

Got the script from here.
http://www.tek-tips.com/viewthread.cfm?qid=1492889&page=6 and changed it
slightly.

Hope it works on xp home, works fine on 7.

On Wed, May 18, 2011 at 3:17 PM, Mike Bonner <bonnmike at gmail.com> wrote:

> With windows xp, tasklist is only available on xp Pro.  vista and 7 should
> have it in all versions by default. (I think)
>
>
> On Wed, May 18, 2011 at 3:00 PM, Graham Samuel <livfoss at mac.com> wrote:
>
>> Since I can't use 'the OpenProcesses' in LC to see what non-LC programs
>> are running in Windows, I thought I'd look for the equivalent command in the
>> cmd.exe command set, hoping in the end to run it via 'shell' from my LC app.
>> The Microsoft documentation explains a function called 'tasklist' which
>> looks promising, but my CMD window keep saying the command is not
>> recognised. Other commands like 'start' and 'ipconfig' work OK. Can anyone
>> with Windows knowledge explain what I'm doing wrong?
>>
>> TIA
>>
>> Graham
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>



More information about the use-livecode mailing list