What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Help writing a batch file

Help writing a batch file
Author: Message:
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
RE: Help writing a batch file
IMO python would be a much better solution to this
python code:
###define function for the processes
import win32pdh,os
def get_processes():
    win32pdh.EnumObjects(None, None, win32pdh.PERF_DETAIL_WIZARD)
    junk, instances = win32pdh.EnumObjectItems(None,None,'Process', win32pdh.PERF_DETAIL_WIZARD)

    proc_dict = {}
    for instance in instances:
        if proc_dict.has_key(instance):
            proc_dict[instance] = proc_dict[instance] + 1
        else:
            proc_dict[instance]=0

    proc_ids = []
    for instance, max_instances in proc_dict.items():
        for inum in xrange(max_instances+1):
            hq = win32pdh.OpenQuery() # initializes the query handle
            try:
                path = win32pdh.MakeCounterPath( (None, 'Process', instance, None, inum, 'ID Process') )
                counter_handle=win32pdh.AddCounter(hq, path) #convert counter path to counter handle
                try:
                    win32pdh.CollectQueryData(hq) #collects data for the counter
                    type, val = win32pdh.GetFormattedCounterValue(counter_handle, win32pdh.PDH_FMT_LONG)
                    proc_ids.append((instance, val))
                except win32pdh.error, e:
                    #print e
                    pass

                win32pdh.RemoveCounter(counter_handle)

            except win32pdh.error, e:
                #print e
                pass
            win32pdh.CloseQuery(hq)

    return proc_ids
x=get_processes()
if synergys.exe in x:
os.system("exit program synergys.exe")#this could be subed with a pid and killtask if you did a dictionary look up
else:
    os.system('"c:\program files\synergy\synergys.exe" -a pieceofcrap:24800 -d FATAL')
    os.system(' "c:\program files\ultramon\ultramon.exe" /d')

This post was edited on 04-21-2009 at 06:47 AM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














04-21-2009 05:43 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Help writing a batch file - by MeEtc on 04-21-2009 at 03:09 AM
RE: Help writing a batch file - by Jarrod on 04-21-2009 at 05:43 AM
RE: Help writing a batch file - by MeEtc on 04-21-2009 at 05:55 AM
RE: Help writing a batch file - by Jarrod on 04-21-2009 at 06:47 AM
RE: Help writing a batch file - by Dempsey on 04-21-2009 at 07:44 AM
RE: Help writing a batch file - by CookieRevised on 04-21-2009 at 04:09 PM
RE: Help writing a batch file - by Dempsey on 04-21-2009 at 05:15 PM
RE: Help writing a batch file - by Mike on 04-21-2009 at 06:00 PM
RE: Help writing a batch file - by MeEtc on 04-21-2009 at 06:24 PM
RE: Help writing a batch file - by MeEtc on 04-22-2009 at 02:27 AM
RE: Help writing a batch file - by Jarrod on 04-22-2009 at 03:35 AM
RE: Help writing a batch file - by MeEtc on 04-22-2009 at 04:26 AM
RE: Help writing a batch file - by CookieRevised on 04-23-2009 at 06:54 AM
RE: Help writing a batch file - by Vilkku on 04-23-2009 at 07:27 AM
RE: Help writing a batch file - by CookieRevised on 04-23-2009 at 07:37 AM
RE: Help writing a batch file - by foaly on 04-23-2009 at 12:01 PM
RE: RE: Help writing a batch file - by CookieRevised on 04-23-2009 at 10:22 PM
RE: Help writing a batch file - by MeEtc on 04-23-2009 at 03:12 PM
RE: Help writing a batch file - by Jarrod on 04-23-2009 at 10:39 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On