Windows XP Community - XPHeads



Reuslt of WMI script.

microsoft.public.windowsxp.wmi


Reply
  #1 (permalink)  
Old 01-02-2008, 07:19 AM
Pradeep Bisht
 
Posts: n/a
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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-01-2008, 08:32 AM
Mark Dormer
 
Posts: n/a
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...
> 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
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-26-2008, 08:35 PM
Andres Olvera
 
Posts: n/a
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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



All times are GMT. The time now is 04:31 PM.








Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0

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