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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Array....

Status
Not open for further replies.

chanman525

IS-IT--Management
Oct 7, 2003
169
US
Hello all. I'm very new to scripting and I need some help figuring out what I'm doing wrong with my array. Basically my goal is to find out if Remote Desktop is enabled on all of the machines at our site. The script works for my machine, but I've tried to add the array and the list of "echo's" and now I'm getting nothing returned into my notepad. Just curious if someone could help me fix what I'm doing wrong.

Sidenote: Some of the stuff in this script might not have anything to do with the script. I got some of this from Sciptomatic so my apologies if it comes off pretty unorthodox. Like I said, I'm pretty new and I'm not entirely sure what all of this is doing quite yet.

Code:
On Error Resume Next

'Sets Constants
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
arrComputers = Array("computer 1","computer 2")
For Each strComputer In arrComputers
WScript.Echo
   WScript.Echo "=========================================="
   WScript.Echo "Computer: " & strComputer
   WScript.Echo "=========================================="

Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
 strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
strValueName = "DeleteTempDirsonExit"
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
StdOut.WriteLine "Remote Desktop Set to " & dwValue 
 
 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
strValueName = "InstanceID"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
StdOut.WriteLine "Remot Desktop Set to: " & strValue
Next
end Function
 
On Error Resume Next tells the script to ignore any errors and keep going. It has its uses, but in the debugging stage you should turn it off so you will get an error message and description.

Comment out the line: On Error Resume Next and run your script again.
 
You have an "end function" at the bottom without a function declaration. The OERN is covering up that error.

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top