PDA

View Full Version : WSH Scripting (Conditional Statements) (W2K)



SADM_Phil
03-10-2004, 11:44 AM
Why is it that everytime I create a script with a 'For...Each...Next' statement; it bombs out on the line 'For Each...?
Here is an example:
C:\>type oswmi.vbs
DIM os
for each os in GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
WScript.Echo os.Version
WScript.Echo os.Caption
WScript.Echo os.CSDVersion
next

C:\>cscript oswmi.vbs
Microsoft (R) Windows Script Host Version 5.1 for Windows
Copyright (C) Microsoft Corporation 1996-1999. All rights reserved.

C:\oswmi.vbs(2, 1) 0x80041003

<P ID="edit"><FONT class="small">Edited by SADM_Phil on 03/10/04 13:18.</FONT></P>

Belaflek
03-11-2004, 07:08 AM
odd..worked for me

SADM_Phil
03-11-2004, 07:41 AM
Would you have to be an administrator to successfully run the script.