Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Startup script stuck!!

Status
Not open for further replies.

mespe

Technical User
Aug 8, 2003
47
0
0
EC
Hello all:

I want to run a script that will send a message when a specific event id is logged in event log.
Script is already written and works fine when I test it from command line.

Now, I am trying to run it from GRoup Policy, in Scripts/Startup Section, when i ran it on my winxp laptop, worked well, the computer starts, offers me to log in, and when I login the script is working (In task managers/proceses I see wscript.exe)

When I run it on a win2k server machine, and restart the server, the server gets stuck with the message "Running startup scripts" and will not show the logon message at all.

My script has a loop in it, of course it is monitoring all the time if an event id happens in event log, so I dont know how to tell it to have it running but at the same time log into the sistem.

And also why does it work in my winxp laptop in local group policy? I have tried other winxp machines and will have the same problem as the server.....

I would really appreciate some help, Im clueless here........
 
You should do some research on vbscript and WMI event notification. Much better solution than an endless loop.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thank you for your answer. I went and read a little about WMI ... very interesting. Now, I did not write the script I am talking about, I practically copied it from the scripting repository and customized to my environment, below is a copy of it (not giving real names of servers)

This script works perfectly from the command line. Problem is when I submit it through Group policy/startup scripts.


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Security)}!\\" & _
strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from __instancecreationevent where " _
& "TargetInstance isa 'Win32_NTLogEvent' " _
& "and TargetInstance.EventCode = '2013' ")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent
' strAlertToSend = objLatestEvent.TargetInstance.User _
' & " attempted to access DatabaseServer."
' Wscript.Echo strAlertToSend
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "account@mydomain.net"
objEmail.To = "IT@mydomain.net"
objEmail.Subject = "Low disk space"
objEmail.Textbody = "Low disk space detected, please check."
objEmail.Configuration.Fields.Item _
(" = 2
objEmail.Configuration.Fields.Item _
(" = _
"smtpserver"
objEmail.Configuration.Fields.Item _
(" = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Loop
 
Another comment:

I just found this thread
where seems the user had same problems as myself, they speak of a Group Policy setting of runing scripts asynchronously
at
Computer Configuration->Administrative Templates->System->Scripts->Run
startup script asynchronously

I am gonna give it a try
 
An interesting tidbit to your script, and you should look into solving this before implementing, is you do not have an indication of which server is reporting the high disk usage. Be kind of difficult if you have multiple servers running this.

As a side note, I think Mark's suggestion is right on. If you want a different solution than MOM, you could look into Last I heard, it is still free.....
 
Thanks for your input. As for which server would be reporting the high disk usage I was thinking to tailor the message of the script on each server...just a line change for our near 8 servers..

I am gonna look into cacti.net.

Although, I am still puzzled at the thought that there must be a way to tell windows to load some script and move forward to load windows so as to have it running at startup...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top