Jump to content

See how long startup scripts take to run


Recommended Posts

Posted

Hi,

 

We have a few startup scripts running. One of them seems to be slowing things down abit. does anyone know of a way i can view how long each script is taking to execute?

 

Thanks

Posted
Try event viewer? See if any scripts are bombing out there, reporting problems? that's what I did when we were having a similar problem
Posted
Only thing i can think of is using Group Policy set "Show Startup Scripts Visable" then manually time it. You should see the command window pop up then. (If they are .bad based)
Posted

Yes this sort of thing can be a pain so what I have done in the past is pipe [ what I can ] in the script to a text / log file [ self de-bugging if you like ] that way I can see what has been done, and what not has been done etc. [ Code in some time stamps on lines or actions after they have been done ]

You could always create a boot log as another option - knock up a script which monitors the other scripts, try and get that to run on a remote station to monitor......

Posted

This How to enable user environment debug logging in retail builds of Windows will create a very large log file of exactly how long each step takes during the logon process and is the most comprehensive way to do it. As it is scripts and probably a couple of slow operations in the script itself mattx's method will be able to tell you precicely what area of the offending script is causing the issue - assuming you add enough log checkin points.

 

http://windowsitpro.com/article/articleid/41876/how-can-i-enable-user-environment-debugging-in-windows-2000-and-later.html

Posted

What I've done in the past is work out which script is going to run last (if you have multiple startup scripts) and then add code to look at the time the script finishes and the time the eventlog says Windows started. That's not a perfect guide to how long the machine took to start up but it's a good guide.

 stTime=dateadd("n",-30,now)
 dt=year(date)&right("00"&month(date),2)&right("00"&day(date),2)
 atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"
 sOffset=right("000" & oShell.RegRead(atb)*-1,3)
 stTime=dt & right("0" & hour(stTime),2)& right("0" & minute(stTime),2) & "00.000000+" & sOffset
 sql="SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'system' and eventcode=6005 and timegenerated>='" & stTime & "'"
 Set wbemobjectset = GetObject("winmgmts:\\.").ExecQuery(sql)
 For Each wbemObject In wbemObjectSet
     sTime=wbemObject.TimeGenerated
 Next
 if sTime<>"" then
   sTime=left(sTime,4) & "-" & mid(sTime,5,2) & "-" & mid(sTime,7,2) & " " & (mid(sTime,9,2) & ":" & mid(sTime,11,2) & ":" & mid(sTime,13,2))
 else
   sTime="1900-01-01 00:00:00"
 end if
 ScriptRunTime=datediff("s",sTime,now)

 

At the end of that bit, ScriptRunTime will be the number of seconds between the machine recording the 6005 "Windows is starting" event and the end of the script.

 

It uses a WMI query to read the event log - I couldn't find a way to say "find the most recent startup event" so I get all startup events in the past 30 minutes and step through them; the last one is treated as the actual machine on time.

 

If you log this to a database then you've got a record of how long each machine takes to start up (and also gives you a log of each time the machine boots)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...