Solved

Performance Logs and Alerts will not run program

Posted on 2009-06-30
10
1,559 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

21 Experts available now in Live!

Get 1:1 Help Now