VB - Check if condition is present

Dell / Pe2950
April 9, 2009 at 12:16:55
Specs: XP Pro SP3, Dual Xeon 5150
I have absolutely no programming experience. Thought that was worth mentioning.

I'm adding a tiny piece of vb code to my login script that will turn Windows Update on and schedule it until I can get WSUS running. I plan on leaving the code in the login script for a little while and thought it would be smart to add a line that checks to see if WU was enabled already. If it is the script should end.

This is the code to enable Windows Update:


Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Set objSettings = objAutoUpdate.Settings

objSettings.NotificationLevel = SCHEDULED_INSTALLATION

Can someone please provide me the vb code that translates to: "if scheduled_installation = 4 then end"



See More: VB - Check if condition is present

Report •

April 9, 2009 at 13:36:16
Scheduled_information will always = 4 as is defined as a constant, not a variable. It is the convention in programming that constants as always written in uppercase to differentiate them from variables which are in lower case.

What you need to do is to check the value of objSettings.NotificationLevel which will be 4 if Update is enabled and something else if it isn't.

If the purpose of the code is to ensure that Auto update is always turned on then it is not necessary to check if it is. Once you have defined the object auto update Object all the hard work is done and you might just as well run the next two lines in any case.


Report •

April 15, 2009 at 07:23:31
Thank you for the information. I will leave everything as I have it.


Report •

Related Solutions

Ask Question