Performance Logs and Alerts will not run program

Posted on 2009-06-30
Last Modified: 2012-05-07
I've got a Win2003 domain controller and I've made a new alert using Performance Logs and Alerts, to keep an eye on something. The alert will log an entry in the application log if I configure it to do so, but no matter what I do I can't get it to run the program I specify.

I make a new alert, and in the Action tab I tick 'Log an entry in the application event log' and 'Run this program'. The program is just a batch file. I wanted to see what it was doing so I modified it to output to a text file instead of the console, but no file appeared, and I even modified it to simply "echo asdf > asdf.txt" and even that didn't work. I gave it an executable instead, and it did nothing. It's just not running the program at all! I had the alert running using a user account with reduced privileges, but I gave it a bloody domain admin acount and it still didn't work!

Anyone got any ideas?
Question by:spectra-qest
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 84

Expert Comment

ID: 24752391
Make sure you've selected at least one argument for the program to run: "Note You must select at least one command-line argument or the program will not run. (This is true regardless of what program you have selected.)"
How to create and configure performance alerts in Windows Server 2003

Author Comment

ID: 24759358
Thanks for the reply.

Giving it an argument seemed to make the test batch file run.

At first I thought it didn't because the only thing my test batch file did was echo asdf to a text file, and I didnt see any file there. But I thought maybe it doesn't have permissions to create a file there, so I added a line to it to stop a service, and when the alert ran, the service was stopped. So it appeared to be actually running the batch file but not creating the text file... So either it doesn't have permissions to create the file - which would be *retarded* because I gave it Domain Admin privileges to test it with - or it's not saving the file in the location I told it to. I figured I'd just give the full path to the file and see if that helped. It did create the text file this time.

Then I passed it the batch file I actually want it to run, and it doesn't work as intended... It was able to stop a service, but the program called by the batch file did not seem to run at all. I know the batch file itself works because I've tested it. I gave it the full path of the program I want it to run, but that had no effect.

The program the batch file calls sends an email... it's just sendEmail from - nothing fancy. But the email doesn't get sent, and the program doesn't output anything. I redirected the program's output to a text file but it didn't output anything.

Augh! Anyone know what's happening?
LVL 84

Expert Comment

ID: 24765846
Try to send the email with blat:
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.


Author Comment

ID: 24769459
Thanks for the suggestion. It still didn't work though :(
LVL 84

Expert Comment

ID: 24781432
If the batch can stop a service, then it's obviously running.
Redirect the blat's output to a text file; do it the following way:
Somewhere at the beginning of th batch, enter (exactly like that):
set LogFile=%~dpn0.log
This will create a log file name with the path and name of the batch file and the extension log.
Then call blat like this (replacing the ... with your arguments):
blat ... >>"%LogFile%" 2>&1

Author Comment

ID: 24782685
That appeared to do nothing...
LVL 84

Assisted Solution

oBdA earned 500 total points
ID: 24789358
But your script stopped the service?
Please post the complete script you're currently using as Code Snippet.

Author Comment

ID: 24790685
I was playing with it overnight, and I found one problem. The system did not have permission to access a file I was referencing. I fixed that, then I realised that it was falling through all the if statements at the beginning of the batch which try to figure out where to go based on the first argument (ie. %1), because the if statements were looking for a piece of text, but the alerts service was passing the expected text with quotes around it.

So I have a check that is basically this:
if "%1"=="expectedtext" goto label
but it's not working because even though I've told the alerts service to pass it expectedtext, it passes "expectedtext".

What can I do to fix this?

Accepted Solution

spectra-qest earned 0 total points
ID: 24791029
*slaps forehead* DUUUUHHH... I just had one of those moments.

Needless to say, I just took the quotes off the %1.

Thanks for trying to help me out though. Points for the effort!

Expert Comment

ID: 33480383
I was struggling with the same issues and I think I discovered another problem. I tried the suggestions of running notepad.exe and bat files etc. to test the "Run this program" with command line arguments. The reason why these things didn't work, I speculating, is because these tests all try to show some sort of a user interface (like a Dos command window or like the notepad window). From what I remembered of programming services in VB6 a few years ago I remembered that the service program cannot have any sort of user interface - it has to run strictly in batch with no stopping for msgboxes or input/ouput forms. I applied this thinking to the performance alert program I wrote (a VB6 program to send an Email using command line parmameters passed to it with no user interface) and it worked!

Hope this helps...


Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question