Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - tools

Reply
 
Old 10-20-2008   #1 (permalink)
phoenix


 
 

tools

If I take the following script.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where
IPEnabled=TRUE")

For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next



I am using Windows Management Instrument, how can I trace where this is
and what all the available other options are.

Are there any better tools ?

My System SpecsSystem Spec
Old 10-20-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: tools


"phoenix" <phoenix@xxxxxx> wrote in message
news:OTInp9oMJHA.5692@xxxxxx
Quote:

> If I take the following script.
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set IPConfigSet = objWMIService.ExecQuery _
> ("Select * from Win32_NetworkAdapterConfiguration Where
> IPEnabled=TRUE")
>
> For Each IPConfig in IPConfigSet
> If Not IsNull(IPConfig.IPAddress) Then
> For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
> WScript.Echo IPConfig.IPAddress(i)
> Next
> End If
> Next
>
>
>
> I am using Windows Management Instrument, how can I trace where this is
> and what all the available other options are.
>
> Are there any better tools ?
Try WMI Code Creator:
http://www.microsoft.com/downloads/d...displaylang=en


My System SpecsSystem Spec
Old 10-20-2008   #3 (permalink)
phoenix


 
 

Re: tools

Fantastic tool.. thank you very much.

Is there something similar with Active Directory ? Or am I pushing my
luck ..





Pegasus (MVP) wrote:
Quote:

> "phoenix" <phoenix@xxxxxx> wrote in message
> news:OTInp9oMJHA.5692@xxxxxx
Quote:

>> If I take the following script.
>>
>> strComputer = "."
>> Set objWMIService = GetObject("winmgmts:" _
>> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>>
>> Set IPConfigSet = objWMIService.ExecQuery _
>> ("Select * from Win32_NetworkAdapterConfiguration Where
>> IPEnabled=TRUE")
>>
>> For Each IPConfig in IPConfigSet
>> If Not IsNull(IPConfig.IPAddress) Then
>> For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
>> WScript.Echo IPConfig.IPAddress(i)
>> Next
>> End If
>> Next
>>
>>
>>
>> I am using Windows Management Instrument, how can I trace where this is
>> and what all the available other options are.
>>
>> Are there any better tools ?
>
> Try WMI Code Creator:
> http://www.microsoft.com/downloads/d...displaylang=en
>
>
My System SpecsSystem Spec
Old 10-20-2008   #4 (permalink)
phoenix


 
 

Re: tools

Can anyone explain the following:

Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("c:\testfile.txt", True)
a.WriteLine("This is a test.")
a.Close



I get the code.. just that where do I find the FileSystemObject and
others like it? I've been using WMI and looking in root/CIMV2.

Please give me a quick difference between the two types.

Cheers,
My System SpecsSystem Spec
Old 10-20-2008   #5 (permalink)
Richard Mueller [MVP]


 
 

Re: tools


"phoenix" <phoenix@xxxxxx> wrote in message
news:OgRX1crMJHA.4248@xxxxxx
Quote:

> Can anyone explain the following:
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set a = fso.CreateTextFile("c:\testfile.txt", True)
> a.WriteLine("This is a test.")
> a.Close
>
>
>
> I get the code.. just that where do I find the FileSystemObject and
> others like it? I've been using WMI and looking in root/CIMV2.
>
> Please give me a quick difference between the two types.
>
> Cheers,
The snippet you gave uses the FileSystemObject. This is available in every
Microsoft operating system since Windows 95. (You must install DSClient on
Win9x and NT clients). I believe it is implemented in vbscript.dll. It has
nothing to do with WMI.

WMI comes with every operating system since Windows 2000, but it can be
installed on older clients. The best resource I know of to learn how to use
WMI and the FileSystemObject is "Microsoft Windows 2000 Scripting Guide":

http://www.microsoft.com/technet/scr....mspx?mfr=true

Introduction to WMI:

http://www.microsoft.com/technet/scr..._overview.mspx

Chapters on dealing with files and disks are linked here:

http://www.microsoft.com/technet/scr..._overview.mspx

Many examples in the Scripting Center. For example:

http://www.microsoft.com/technet/scr...e/default.mspx

The classes available in WMI depend a bit on the OS. I think the links above
include a way to "discover" which classes are available, but I look for
example code in the Script Center.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 10-20-2008   #6 (permalink)
mayayana


 
 

Re: tools

That's a big question. First, WMI has nothing to
do with VBScript directly. It's a complete system
on it's own, with its own objects and syntax. WMI
just happens to be one tool that is accessible through
VBScript. If you don't have a copy of the WMI help
file you should try to find that. There used to be a
WMI SDK that could be downloaded, with samples and
a good help file. Looking around now I'm finding the
typical problem with getting Microsoft docs: The links
to the SDK are broken. Mentions of it only point to
the "download center", which is a generic MS download
page. A search there turned up nothing.

It may be that the WMI SDK, like some others, is now
only available as part of the giant Win32 platform SDK.
That presents some problems. First, you'll need a high
speed connection to get it. Then you probably have to
allow the install of Microsoft's "Windows Genuine Advantage"
spyware. Worse, MS created a new, incompatible help system
in their recent SDKs. I think they call it HTML Help 2. One
apparently needs Visual Studio 2008 to read the new help.
There's a free program called HelpExplorer that also seems to
work, but HelpExplorer can't provide a master index to the
large number of help files in the platform SDK.

The original help file, if you can find it, will be named
wmisdk.chm.

There's also a WMI group:
microsoft.public.win32programmer.wmi

What you posted is VBScript using the FileSystemObject,
which is one of the many COM objects available to script.
There isn't really a master list of those. There are a handful
that are officially part of the Windows Script Host, such
as FSO, Dictionary, WScript.Shell, etc. Those objects are
in scrrun.dll and wshom.ocx. You can inspect those files with
an object browser. A free object browser is here:
http://www.tlviewer.org/tlviewer/

To make a long story very short, COM objects are specifically
designed programming tools that are registered in the Registry.
Any number of objects can reside in a given PE file (exe, dll, ocx).
Part of the COM spec. is that these files also have a "type library" --
either internal or in an external file -- which describes the methods
and properties of objects. The type library makes a COM object
"self-describing". An object browser is basically a specialized
type library reader that allows you to see what objects are avaiaable
and what their methods are. (Though an object browser rarely
provides enough information to use an object. It's mostly sort
of a crib sheet for reference.)

In VBScript, using the CreateObject method, you can use
many of the COM objects registered on your system, thereby
expanding the abilities of VBS. Such objects are not inherent
to VBS itself. The object must be installed/registered on your
system in order to use it.

For the basic objects connected with WSH, like FSO, you
can look up the methods in the WSH help file. Then there are
objects like Shell.Application that are on nearly all Windows
systems (Shell.App. was added with Active Desktop/Win98), but
they're not official scripting objects so they're not in the help file.
Then there are automation objects, like Internet Explorer and
MS Word. You can use VBS with them. There are also various
3rd-party (non-Microsoft) components available.

So most of what VBS can do is derived from one object or
another, but objects can be all sorts of things.

Quote:

> Can anyone explain the following:
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set a = fso.CreateTextFile("c:\testfile.txt", True)
> a.WriteLine("This is a test.")
> a.Close
>
>
>
> I get the code.. just that where do I find the FileSystemObject and
> others like it? I've been using WMI and looking in root/CIMV2.
>
> Please give me a quick difference between the two types.
>



My System SpecsSystem Spec
Old 10-20-2008   #7 (permalink)
mayayana


 
 

Re: tools

>
Quote:

> The snippet you gave uses the FileSystemObject. This is available in every
> Microsoft operating system since Windows 95. (You must install DSClient on
> Win9x and NT clients). I believe it is implemented in vbscript.dll
It's actually in scrrun.dll and comes with the WSH,
which is optional on Win98 and an extra install on
Win95. It can also be removed, though.There seems
to be a percentage of system admins who regard
WSH as a big securtiy risk and like to remove/disable it.

Scrrun.dll is also redistributable, so it could be added/
updated on a target system regardless of the WSH
status of that system.

(Then there are the security issues connected with
..VBS. Many AV products will allow an unknown EXE to
run without problem but will sound the alarm -- or even
block execution -- when a .vbs file is run that's using
FSO. That's not really a limitation with FSO but it's a
realistic limitation in terms of how much confidence one can
have in distributing scripts.)


My System SpecsSystem Spec
Old 10-20-2008   #8 (permalink)
Pegasus \(MVP\)


 
 

Re: tools


"phoenix" <phoenix@xxxxxx> wrote in message
news:OgRX1crMJHA.4248@xxxxxx
Quote:

> Can anyone explain the following:
>
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set a = fso.CreateTextFile("c:\testfile.txt", True)
> a.WriteLine("This is a test.")
> a.Close
>
>
>
> I get the code.. just that where do I find the FileSystemObject and
> others like it? I've been using WMI and looking in root/CIMV2.
>
> Please give me a quick difference between the two types.
>
> Cheers,
You'll find all the basic VB Scripting objects (including the File System
Object) explained in the downloadable file script56.chm.


My System SpecsSystem Spec
Old 10-21-2008   #9 (permalink)
Paul Randall


 
 

Re: tools

Perhaps you could try searching msdn.com for the two words:
adsi matic

-Paul Randall

"phoenix" <phoenix@xxxxxx> wrote in message
news:uNEhFupMJHA.260@xxxxxx
Quote:

> Fantastic tool.. thank you very much.
>
> Is there something similar with Active Directory ? Or am I pushing my
> luck ..
>
>
>
>
>
> Pegasus (MVP) wrote:
Quote:

>> "phoenix" <phoenix@xxxxxx> wrote in message
>> news:OTInp9oMJHA.5692@xxxxxx
Quote:

>>> If I take the following script.
>>>
>>> strComputer = "."
>>> Set objWMIService = GetObject("winmgmts:" _
>>> & "{impersonationLevel=impersonate}!\\" & strComputer &
>>> "\root\cimv2")
>>>
>>> Set IPConfigSet = objWMIService.ExecQuery _
>>> ("Select * from Win32_NetworkAdapterConfiguration Where
>>> IPEnabled=TRUE")
>>>
>>> For Each IPConfig in IPConfigSet
>>> If Not IsNull(IPConfig.IPAddress) Then
>>> For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
>>> WScript.Echo IPConfig.IPAddress(i)
>>> Next
>>> End If
>>> Next
>>>
>>>
>>>
>>> I am using Windows Management Instrument, how can I trace where this is
>>> and what all the available other options are.
>>>
>>> Are there any better tools ?
>>
>> Try WMI Code Creator:
>> http://www.microsoft.com/downloads/d...displaylang=en

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
PRO TOOLS and 64 bit Software
Administrative Tools...gone! Vista General
Can't move Administrative Tools to System Tools? Vista installation & setup
Smart Tools Vista hardware & devices
Mandatory Integrity Control (MIC) tools? Biba tools? Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46