Monitor Startup Programs VB script Error

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Monitor Startup Programs VB script Error

Post by Rain » Fri Jan 20, 2006 2:20 pm

I get the following error when running the script below.
Microsoft VBScript compilation error:1006
Expected ')'
Line 14, Column 85

//This script retrieves a list of applications and services that are set to run
//when Windows starts up. It is a useful defence against potential spyware/malware.
//This script keeps a log of startup programs and will alert the user if a change has
//occured and email the SysAdmin. Schedule the macro to run once a day.

//Modify these three lines
Let>logfile=c:\logs\startups.txt
Let>mail_server=mail.domain.com
Let>recipient=[email protected]

VBSTART
Function GetStartupProgs
On Error Resume Next
Dim s
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_StartupCommand",,48)
s = ""
For Each objItem in colItems
s = s + "________________" & vbCRLF
s = s + "Name: " & objItem.Caption & vbCRLF
s = s + "Command: " & objItem.Command & vbCRLF
s = s + "Description: " & objItem.Description & vbCRLF
s = s + "Location: " & objItem.Location & vbCRLF
s = s + "Name: " & objItem.Name & vbCRLF
s = s + "SettingID: " & objItem.SettingID & vbCRLF
s = s + "User: " & objItem.User & vbCRLF
Next
GetStartupProgs = s
End Function
VBEND

//get start up command details
VBEval>GetStartupProgs,progs

//If a log already exists, compare it.
IfFileExists>logfile
//a log exists, compare it to this one
ReadFile>logfile,oldprogs
Let>comp_progs=%progs%%CRLF%

//if there's a change, alert user
if>oldprogscomp_progs
MessageModal>Startup Config Has Changed, Emailing SysAdmin
//email system admin
SMTPSendMail>recipient,mail_server,logs@%mail_server%,logs,Startup Changed on %COMPUTER_NAME%\%USER_NAME%,progs,
endif

//delete the old copy
DeleteFile>logfile
endif

//write to logfile
WriteLn>logfile,r,progs


Thanks for any help with this script.

Rain

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 20, 2006 2:31 pm

Hi,

Try it now. It's 'cos I didn't disable smiilies when I posted it so it replaced 8) at the end of line 14 with the html for a smilie!

I've reposted it with smilies disabled so it should now be ok.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri Jan 20, 2006 3:26 pm

Thanks it's working now.
Very nice script by the way :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts