Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Script not working properly

  • Please log in to reply
No replies to this topic

#1 hackman2007


  • Members
  • 28 posts
  • Local time:01:13 AM

Posted 01 December 2009 - 02:48 PM

This isn't exactly a programming problem, but this folder is the closest I could find that would cover this type of issue.

I'm trying to get a Windows Powershell script working so that when ehrec.exe launches it runs a certain batch file (the batch file closes out some of my CPU/GPU intensive applications).

I'm using an if loop to cycle through, but for some reason the else is not being processed. In other words, no matter what the if is always being executed.

Also, if anyone knows a better way to accomplish this (rather than re-running Resume.bat over and over) please let me know.

Here is my code:
$Process = Get-Process | Where-Object {$_.ProcessName -eq "ehrec.exe"}
If (!($Process))
	"Process is running"
	invoke-item C:\Users\hackman2007\Desktop\Suspend.bat
	invoke-item C:\Users\hackman2007\Desktop\Resume.bat

Edited by hackman2007, 01 December 2009 - 02:50 PM.

BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users