Real Geek Forums  

Go Back   Real Geek Forums > Archives > Operating Systems > Windows XP > Windows XP WMI

Notices

Reply

Reuslt of WMI script.

 

LinkBack Thread Tools Display Modes
Old 01-02-2008, 07:19 AM   #1 (permalink)
Default Reuslt of WMI script.

Hello,

I have a script with me, and I want the result of that script in a excel
file.So what is the command for that.
Thanks in advance.

Script -

strComputer = "."
Set objFso = CreateObject("Scripting.FileSystemObject")
strFile = "c:\Scripts\12.xls"
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_Service")

For Each objSWbemObject In colSWbemObjectSet
Wscript.Echo "Display Name: " & objSWbemObject.DisplayName & vbCrLf & _
" State: " & objSWbemObject.State & vbCrLf & _
" Start Mode: " & objSWbemObject.StartMode
Next


Pradeep Bisht
Guest
 
Posts: n/a
Reply With Quote  
Old 02-01-2008, 08:32 AM   #2 (permalink)
Default Re: Reuslt of WMI script.

Here you go

'-------------------------------------------------------------------------------------
Const ForWriting = 2
strComputer = "."
Set objFso = CreateObject("Scripting.FileSystemObject")
Set strFile = objFSO.OpenTextFile("c:\Scripts\12.csv", ForWriting, -2)
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_Service")
strFile.writeline "Display Name" & "," & "State" & "," & "Start Mode"
For Each objSWbemObject In colSWbemObjectSet
strFile.writeline objSWbemObject.DisplayName & "," & objSWbemObject.State &
"," & objSWbemObject.StartMode
Next
strFile.Close
'---------------------------------------------------

Regards
Mark Dormer

"Pradeep Bisht" <PradeepBisht@discussions.microsoft.com> wrote in message
news:2B9A696D-C170-4A8B-BA9C-83D27E3047E2@microsoft.com...
Quote:
> Hello,
>
> I have a script with me, and I want the result of that script in a excel
> file.So what is the command for that.
> Thanks in advance.
>
> Script -
>
> strComputer = "."
> Set objFso = CreateObject("Scripting.FileSystemObject")
> strFile = "c:\Scripts\12.xls"
> Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)
> Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_Service")
>
> For Each objSWbemObject In colSWbemObjectSet
> Wscript.Echo "Display Name: " & objSWbemObject.DisplayName & vbCrLf & _
> " State: " & objSWbemObject.State & vbCrLf & _
> " Start Mode: " & objSWbemObject.StartMode
> Next
>
>

Mark Dormer
Guest
 
Posts: n/a
Reply With Quote  
Old 03-26-2008, 09:35 PM   #3 (permalink)
Default RE: Reuslt of WMI script.

You can also try this one out:

strComputer = "."

Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_Service")

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.Workbooks.Add()

objExcel.Cells(1,1) = "Display Name"
objExcel.Cells(1,2) = "State"
objExcel.Cells(1,3) = "Start Mode"
objExcel.Range("A1:C1").Font.Bold = True

intRow = 2
For Each objSWbemObject In colSWbemObjectSet
objExcel.Cells(intRow,1) = objSWbemObject.DisplayName
objExcel.Cells(intRow,2) = objSWbemObject.State
objExcel.Cells(intRow,3) = objSWbemObject.StartMode
intRow = intRow + 1
Next

objExcel.Columns("A:C").Autofit
objWorkbook.SaveAs "C:\Scripts\Services.xls"
objExcel.Quit

Andres Olvera
Guest
 
Posts: n/a
Reply With Quote  
Reply

Tags
None

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
AD GPO log on script failure UCD-IT Windows Vista Networking & Sharing 1 06-27-2006 10:33 PM
Help with this script Dumb Luck Windows XP WMI 0 01-31-2006 07:11 PM
Need help for my script. Newbie Windows XP WMI 1 09-28-2005 04:16 PM
fix WMI via script? emebohw@netscape.net Windows XP WMI 1 01-17-2005 03:49 PM
VB WMI Script David J Duryea Windows XP WMI 0 08-26-2004 01:27 AM


All times are GMT. The time now is 01:09 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2005 - 2007 RealGeek.com. All rights reserved.

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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90