Solved

Performance Logs and Alerts will not run program

Posted on 2009-06-30
10
1,560 Views
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?
0
Comment
Question by:spectra-qest
  • 5
  • 4
10 Comments
 
LVL 83

Expert Comment

by:oBdA
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
http://support.microsoft.com/kb/324752/
0
 

Author Comment

by:spectra-qest
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?
0
 
LVL 83

Expert Comment

by:oBdA
ID: 24765846
Try to send the email with blat: http://www.blat.net/
0
 

Author Comment

by:spectra-qest
ID: 24769459
Thanks for the suggestion. It still didn't work though :(
0
 
LVL 83

Expert Comment

by:oBdA
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
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:spectra-qest
ID: 24782685
That appeared to do nothing...
0
 
LVL 83

Assisted Solution

by:oBdA
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.
0
 

Author Comment

by:spectra-qest
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?
0
 

Accepted Solution

by:
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!
0
 

Expert Comment

by:LHannam
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...

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Update not working 12 115
Auto-Enrollment Group Policy 2 44
Share and Advanced Sharing permissions 8 85
User profile Size Report 3 65
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found listed in my profile here: http:…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now