Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Performance Logs and Alerts will not run program

Posted on 2009-06-30
Medium Priority
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 85

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 http://caspian.dotconf.net/menu/Software/SendEmail/ - 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 85

Expert Comment

ID: 24765846
Try to send the email with blat: http://www.blat.net/
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.


Author Comment

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

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 85

Assisted Solution

oBdA earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

604 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