DOWNLOAD THE CODE:
Download the Code 9100.zip

Windows Management Instrumentation (WMI) is a scriptable, scalable management infrastructure. WMI is part of Windows 2000 (but available for Windows NT 4.0 and Windows 9x) and can help you manage your enterprise systems, applications, and networks as they become large and complex.

You'll find that WMI has several key features that are extremely valuable in solving the complex administrative tasks that challenge you today. Some of those features and capabilities are

  • Uniform Scripting API
  • Discoverability and navigation
  • Query capability
  • Powerful event publication and subscription

However, what I find most exiting about WMI is its remote administration capabilities. Objects that you manage within WMI are, by definition, available to applications and scripts both locally and remotely. No additional work is necessary for managing remote objects.

Before I delve into the technical details of WMI, let me give you some examples of the power this feature offers. With WMI, you can

  • Identify and list all services on a server that you have configured to run in Automatic Start mode but that are currently stopped
  • Identify and list all the NTFS partitions on a server that have less than 10 percent free space left
  • Execute a backup on a Microsoft SQL Server, then dump the transaction log
  • Launch a program on your server through a WMI method
  • Set up an event consumer that watches for a specific event in the system log, then sends an email message when that event occurs.
  • Reconfigure your event consumer script to request a system event whenever a server's CPU utilization exceeds 90 percent

Now, before you say, "Well, I don't need WMI to do all that," let me tell you that you can do everything that I identified above and

more . . . ON A REMOTE MACHINE! You need a security context to run under <username> and <password>, but you can use WMI to remotely execute a program.

With a Windows Script Host (WSH) script called exec.vbs (which I have made available to "IIS Administrator" subscribers in the IIS Administrator Code Library [http://www.iisadministrator.com]), you can execute programs remotely. Consider the following WSH script command and its parameters:

cscript exec.vbs /e "C:\Program Files\Internet _ 
		Explorer\Iexplore.exe" /s "TargetServer"  /u _
		"Administrator" /w "Password"

This command lets you run Microsoft Internet Explorer (IE) on a completely different computer called "TargetServer." Notice that you need to include an account and password that has security privileges on the remote machine.

WMI is modeled on the Web-Based Enterprise Management (WBEM) initiative and the Common Information Model (CIM) that the Distributed Management Task Force (DMTF) adopted. WMI provides a rich, extensible object model that lets you manage computer systems in a consistent, scriptable way—locally or remotely. Most core OS information and services are already instrumented as part of the basic WMI system that comes with Win2K and many other OSs, including third-party services that are under development.

Full documentation about using WMI (and building software that leverages WMI) is available in the WMI software development kit (SDK), which is part of the Microsoft Developer Network (MSDN) Win2K Platform SDK. You can also download the core WMI components needed for NT 4.0 and Win9x systems from this site.

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Hello, i tried this script and always get the following error: Error 0x1A8 occurred in connecting to server selma. Error description: Object required.

Please check the server name, credentials and WBEM Core

commandline use was : cscript exec.vbs /e "C:\test.bat" /s "selma" /u "Administrator" /w "password"

Any ideas ? thanks a million Andi

Andreas Appelbaum

This seems to happen if you do not have a profile on the remote machine. I am having the same problem and hope someone has a resolution ...

David Ell

Even I have the same problem. Forget about a profile on a remote machine, this code does not work on the local machine as well. I have a standalone Win 2000 Prof running and I get the same error when I say <br><br> CScript fileman.vbs /T "c:\AuthTes t" /s "VinodKumar" /U "Administrator" /W "issi" <br><br> where VinodKumar is the name of my local machine and Administartor is the default account. <br><br> Anybody with a soluition..

Shiva Ram

Hi All. It works GOOD.... Also with a Remote Server. BTW... you need a "WBEM" Component on the Remote Server !!! Without this Component , this Script Will NOT runs for the Remote Server , and will massage you this Error - Error : 0x1A8 occurred in connecting to server selma. Error description: Object required. Please check the server name, credentials and WBEM Core.

Alex Frenkel

Someone is going to have to help...I thought that WMI was a core component of Windows 2000??

How or where do we add a WBEM component to our remote server ? It's pretty obvious that either we have the wrong syntax or by default WMI cannot work with these admin scripts like exec.vbs.

Ian

I just want to know why 2000 os is not covered. I know that the WMI components are works as a serivec on 2000. But some times 2000 also gives error error's like WMI core components are missing. This hapens when ever we are installing any program. Can i know what is the reason for this. and is installing WMI components is the solution.

It' s good

Can someone please tell me WHAT is the solution to the "......Object required" problem/error as described above? Cant get exec.vbs to work . . . .

Magnus Lund

I get this error Message when i boot up my Thinkpad T40 running Win 2000Pro: "WinMgmt.exe has generated errors and will be closed by the Windows. You will need to restart your program. An error log has been created"

Then when i access the log I find this: "Fri Jan 09 10:33:02 2004) : core was asked if ok to unload and returned 0x1(Fri Jan 09 10:34:44 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Wed Jan 14 12:01:25 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Wed Jan 14 14:30:56 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Jan 26 15:21:45 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Tue Jan 27 07:18:32 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Tue Jan 27 07:54:34 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Tue Jan 27 08:23:37 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Thu Jan 29 13:48:46 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Fri Jan 30 15:53:44 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Sat Jan 31 09:25:31 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Sat Jan 31 09:30:07 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Feb 02 07:32:50 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Feb 02 13:28:04 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Feb 02 14:51:42 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Tue Feb 03 15:36:54 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Thu Feb 05 11:27:42 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Feb 09 08:00:46 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Mon Feb 09 14:19:02 2004) : core is being shut down by WinMgmt.exe, it returned 0x0(Fri Feb 13 07:43:05 2004)......" This last part Core is being Shut down by WinMgmt.exe... keeps repeating up to now.

In addition not only does the error window pop up at restart and log on but it keeps poping up multiple times while i am working then it stops.

What is going on, can anyone help?

Innocent

Hello all! Try to use "/u machinename\username" or "/u domain\username"

activenet

This is a bit of a sticky wicket. I own a stand-alone laptop Dell Inspiron 8000 that I purchased for my daughter as her college graduation gift. She used it for a couple years, and then gave it back to me since she had upgraded to something else. I then signed on w/ BellSouth FastAccess DSL and purchased a firewall. One of the log alerts indicated Windows Management Instrumentation. My comment is a question: Is it possible that this creep I work with and his computer-savvy lady friend in the company's ITS Dept are spying on me? If possible, then my suspicions are confirmed. Please let me know. I have already filed a complaint with BellSouth's internet abuse department. Thank you for your time, and I look forward to your response.

Diane Judson

When I launch the program. The process is running in the task manager but there is no visual opening of the application on screen....Any ideas why?

Male Stenson

I am also getting the same object required error even if I use correct syntax. Did anyone of u able to execute this script successfully. If it is explain how u did. Where u downloaded WBEM component. Thanks.

Kabil

After i log in, my system the following error message display: WinMgmt.exe has generated error and you will be closed by window,repeated contineously not able to desktop.

Pls solve my problem.

afsar ali

I had the same 'success' with this as Diane did. I ran the script as a bat file in the same directory as the exec.vbs. The task manager shows that the process (i.e. notepad.exe) is running on the remote, but no gui appears. Also, the process seems to be doing nothing. From what I've read, this is the result of a 'security fix' by Microsoft in one of their service packs (W2k SP4, I believe). Is there a workaround for this? Symantec's anti-virus server at least still seems capable of deploying and running its client software on remote machines where it hasn't previously been installed, suggesting to me that remote execution is possible.

Jim Dean

test

Anonymous User

See More Comments  1   2