troubleshooting Question

VBS to run on specific OU

Avatar of 056044787
056044787Flag for Israel asked on
Visual Basic ClassicVB ScriptMicrosoft Legacy OS
9 Comments1 Solution445 ViewsLast Modified:

I have this script, it can run automaticly on each computer on the computers OU.
I need this script to run on other OU (named UK). what do i have to change in this code in order to implement this?

Set colComputers = GetObject("LDAP://CN=Computers, DC=Domain, DC=com")
set fso=CreateObject("scripting.filesystemobject")
For Each objComputer in colComputers
	strComputer = objComputer.CN
	on error resume next
	set fOut=fso.CreateTextFile(strTargetPath & strComputer & ".txt", true)
	if Err.Number<>0 then
		set fOut=fso.CreateTextFile(strTargetPath & "INVALID_NAME" & i & ".txt", true)
		fOut.WriteLine "Computer name: " & strComputer
		fOut.WriteLine ""
	end if
' ----------
	'Sub KBcheck()
Const HKEY_LOCAL_MACHINE = &H80000002
'strComputer = "l-yairn"
Set objRegistry = GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB955839"
strValueName = "Installed"
objRegistry.GetDwordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
      	fOut.WriteLine   "No value - You should install KB955839"
		Wscript.Echo "No value - You should install KB955839"
    If strValue = 1 then 
	'intValue = 3
	'objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intValue
	' Wscript.Echo "value exist"
	 fOut.WriteLine  "KB exist"
	 Wscript.Echo  "KB exist"
    End If
End If
if Err.Number=0 then
		on error goto 0
'end sub
' -----------
		Wscript.Echo  "Computer not available"
		'fOut.WriteLine "Computer not available"
	end if
	on error goto 0
	set fOut=nothing
set fso=Nothing
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros