Quantcast

Maximum PC

It is currently Sat Dec 27, 2014 3:57 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Need to create a script of some kind
PostPosted: Sun Nov 22, 2009 5:10 pm 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
Just as a warning, I am not good at scripting. I can do a little, but nothing advanced. Now on to what I want to accomplish.

I want to be able to launch a batch file at the creation of a certain process (ehrec.exe).

Right now, my current method is to use the Windows Task Scheduler to create a task to run my batch files at the appropriate time. This takes WAY too much effort and foresight. What I want to do is set Windows to record something and automatically launch the batch file when it starts the appropriate process.

Anyone have a clue as to how to accomplish this?

If you need to see my current batch files, let me know.

Again, I'm not a pro at batch files, scripting or programming, so go easy on me. I just know enough to get in trouble and break things.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 5:16 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24238
Location: Granite Heaven
So, you have a process, ehrec.exe, and you want to run a batch file immediately before that process is executed?

What is triggering the execution of ehrec.exe?


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 5:24 pm 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
Jipstyle wrote:
So, you have a process, ehrec.exe, and you want to run a batch file immediately before that process is executed?

What is triggering the execution of ehrec.exe?


When you set Windows Media Center to record it will automatically start ehrec.exe.

I tried setting it up through the Event Viewer, but Microsoft stupidly decided to write to the Event Viewer ONLY when the recording is finished not when the process actually starts.

But you're right, immediately before or right after the launch of ehrec.exe. I'm not picky. As long as it launches sometime before or within a minute or two of the recording process.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 5:54 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24238
Location: Granite Heaven
Hrm.

Well, one method that occurs to me is to have a process running in the background that monitors current processes. When ehrec.exe launches, the background process launches your script.

If it was unix, I could whip it up in 5 minutes .. but windows scripting is something I haven't started learning yet. I'm waiting for my W7 RTM so I can learn windows powerscripting.

Hopefully someone will pop in soon.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 6:01 pm 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
Jipstyle wrote:
Hrm.

Well, one method that occurs to me is to have a process running in the background that monitors current processes. When ehrec.exe launches, the background process launches your script.

If it was unix, I could whip it up in 5 minutes .. but windows scripting is something I haven't started learning yet. I'm waiting for my W7 RTM so I can learn windows powerscripting.

Hopefully someone will pop in soon.


I have cygwin installed on my computer, but I'm not sure that will help.

Hopefully someone pops in here that knows how to do this.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 7:18 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Jipstyle wrote:
I'm waiting for my W7 RTM so I can learn windows powerscripting
You don't need to wait for W7 to get into power shell :)

hackman, can you go into a little more detail what you want to happen? Are you kicking off something and you want to have something else happen at the same time? Does the other process start on its own? I can think of several different ways to go about it but I want some more detail before I send you down a path (or spend any time on it myself).


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 22, 2009 7:50 pm 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
All right, I'll go into as much detail as I can.

The ehrec.exe process is started by Windows Media Center when you schedule a recording. The directory it's in is C:\Windows\eHome\ehrec.exe. It will not let you directly access the executable because it belongs to the Network Services user. You cannot change the owner of this process even if UAC is off. I have not tried logging in as the administrator and seeing if it will let me.

When the ehrec.exe starts, it starts recording on the channel you set Windows Media Center to record on. After it is finished, the process terminates.

What I want to do is, when this this process launches I want to be able to run a batch file that pauses the Folding@Home GPU client (I'm using PSSuspend from Microsoft TechNet). After the process terminates, it would be nice to have the reverse as well so when the process terminates the Folding@Home GPU client starts back up. If you try to record while GPU folding the resulting recording is glitchy and jumps all over the place.

So I guess in short, the process starts from Windows Media Center when it starts working on the current recording. After the recording, it will terminate and disappear.

Need any other information?


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 5:11 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Let me look into that PSSuspend deal. It sounds like you need to have a service running that watches for that process and then stops the F@H client (would it be acceptable to "kill" that process and then start it up again later?)

I am sure I can do it... as far as from the script side I can't think of something specifically to do it...

Are you running Windows 7?


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 5:47 am 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
CrashTECH wrote:
Let me look into that PSSuspend deal. It sounds like you need to have a service running that watches for that process and then stops the F@H client (would it be acceptable to "kill" that process and then start it up again later?)

I am sure I can do it... as far as from the script side I can't think of something specifically to do it...

Are you running Windows 7?


Yeah, I can safely kill the process as well with no ill effects. In fact, I did that until I found PSSuspend.

I found a program that can almost do what I want, but because I'm not the right user it won't let me monitor the specific process (called System Scheduler Professional).

Yes, I am using Windows 7.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 6:09 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Great, this might make life easier. Windows 7 has a concept of a "triggered" service. I am looking into event based triggers (say for example, that process starting). If you have F@H running as a service, we can change it's start up type, I think.

So basically you want this kind of behavior:
F@H runs all the time.
ehrec.exe starts -> stop F@H
ehrec.exe ends -> start F@H

I *THINK* this can be done with the triggered services. Otherwise I am back to creating a service in .net to watch for it and manage it. Should be pretty easy to do if you have the watcher service starting at the system level.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 6:13 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Here is a start:

I can't play with the Win7 side of things until I get home... but I can look at creating that watcher service if you want?

http://windowsteamblog.com/blogs/develo ... ction.aspx


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 6:51 am 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
The GPU client does not run as a service, but I think by using a resource kit I can make it one.

I don't have time to try it right now, but will try it later today and get back to you.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 7:16 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Well if it doesn't run as a service then the watcher service seems to be the way to go. I can probably whip one up in a couple days. I will make it configure-able to handle whatever processes you want it to watch.. I can see this being useful for more than just you, so it seems like a worthwhile effort.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 8:07 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
I am hardcoding for now...

what is the F@H process name?

I haven't run the GPU client... do you run the CPU client as well? Do you know how to distinguish the processes?

Code:
taskkill /F /IM Folding@Home.exe


http://foldingforum.org/viewtopic.php?f=50&t=10902

What process should I be looking to "kill"?


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 8:43 am 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
The processes that need to be stopped are:

FahCore_11.exe
FahCore_12.exe
FahCore_13.exe
FahCore_14.exe

(Some of those may not exist, but may in the future)

Those are the only processes that need to be stopped as they do all the processing.

I don't run any of the CPU clients.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 9:38 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Safe to assume that I could attempt to start each of those processes (for now) and if it fails just move on with life?


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 9:42 am 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
CrashTECH wrote:
Safe to assume that I could attempt to start each of those processes (for now) and if it fails just move on with life?


Well, that may be a bit more difficult.

Once you kill those processes it no longer folds. To start it folding again you have to start the client again. Which would be Folding@HomeGPU.exe or something of that nature. What might be easier is to make a batch file and have it start up that way (I've done this, let me know if you need a batch file to start it).

Whatever you decide is fine.


Last edited by hackman2007 on Mon Nov 23, 2009 9:46 am, edited 1 time in total.

Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 9:45 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Do you have VS 2008? C# Express should work fine. I have the service set up with an installer and everything but I am not sure I can test it as I don't have WMC or FAH here...

I can dropbox it for you and you can install it?

You don't have to have VS but I figured it would be easier to debug.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 11:23 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
http://dl.dropbox.com/u/2821360/ServiceWatcher.7z

Want to take a look at it? It should mostly work. It will check once every 1000ms the processes that are running (1 second might be too fast?). It might also be too slow, it would depend how many processes are running and how the WMC process works. If there is a bit of lag time before it starts recording, 1-5 seconds is probably acceptable.

It needs to be expanded to be dynamic.... and I will eventually get there but I wanted to put this in your hands and see how it worked.


Top
  Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 11:54 am 
Malware specialist
Malware specialist
User avatar

Joined: Sun Apr 03, 2005 12:49 pm
Posts: 11696
Location: Kansas City, KS
I'm not sure how to install it.

7zip won't unzip the files (just says it cannot output the files), but clicking into the directory works.

I do not have VS 2008, but I can get it (I think).

Edit: Yes, I can get VS 2008 Professional from my school. It's a bit large so I'll give it a test later tonight (bandwidth cap sucks).

I'll play around with it some tonight when I get home and update this post.

I really appreciate you doing this for me by the way


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.