Link to home
Start Free TrialLog in
Avatar of spectra-qest
spectra-qestFlag for Australia

asked on

Performance Logs and Alerts will not run program

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?
Avatar of oBdA
oBdA

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
http://support.microsoft.com/kb/324752/
Avatar of spectra-qest

ASKER

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?
Try to send the email with blat: http://www.blat.net/
Thanks for the suggestion. It still didn't work though :(
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
That appeared to do nothing...
SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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...