![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | need help dumping to excel Here's a link to the long script I'm working with: http://www.gcpsite.com/script.txt All I'm trying to do is pull information and dump it into a spreadsheet, one column per server. I had this script working by dumping everything to a text file, but for the purposes of working with this data it would be MUCH better in a spreadsheet. The number of servers I will be ultimately running this against is just impractical to cut/paste from the text file to Excel. Thanks in advance for any help. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: need help dumping to excel On Feb 4, 9:46*am, insanity...@xxxxxx wrote: Quote: > Here's a link to the long script I'm working with: > > http://www.gcpsite.com/script.txt > > All I'm trying to do is pull information and dump it into a > spreadsheet, one column per server. *I had this script working by > dumping everything to a text file, but for the purposes of working > with this data it would be MUCH better in a spreadsheet. *The number > of servers I will be ultimately running this against is just > impractical to cut/paste from the text file to Excel. *Thanks in > advance for any help. look at the script and doing a brief search of the net, I would offer the following for consideration: First, have a look at this reference ... http://www.eggheadcafe.com/software/...r-the-typ.aspx Then from it, I created this little subroutine that could be used to greatly simplify your long lists of cell locations and properties ... ' Assuming strComputer and objSheet are defined correctly, for example ... ' Set colItems = GetObject("winmgmts:{impersonationLevel=impersonate}!\ \" _ & strComputer & "\root\cimv2:Win32_Processor") col = 2 rowStart = 2 FillCol(col, rowStart, colItems, objSheet) Sub FillCol(col, row1, cItems, oSheet) Dim oItem, oPropertySet, oProperty, y row = row1 For Each oItem in cItems Set oPropertySet = oItem.Properties_ For Each oProperty In oPropertySet objSheet.Cells(col, row).Value = eval("oItem." & oProperty.name) row = row + 1 Next ' Property Next ' Item End Sub ' FillCol This will significantly reduce the number of lines of code, thereby improving readability, maintenance and reducing the potential for errors in typing. If you have some other particular problem, you'll need to restate your problem. Tom Lavedas *********** http://there.is.no.more/tglbatch/ |
My System Specs![]() |
| | #3 (permalink) |
| | Re: need help dumping to excel On Feb 4, 11:20*am, Tom Lavedas <tglba...@xxxxxx> wrote: Quote: > I'm not certain what your question is, but after taking a very quick > look at the script and doing a brief search of the net, I would offer > the following for consideration: > > First, have a look at this reference ... > > *http://www.eggheadcafe.com/software/...-do-i-discover.... > > Then from it, I created this little subroutine that could be used to > greatly simplify your long lists of cell locations and properties ... > > ' Assuming strComputer and objSheet are defined correctly, for > example ... > ' > Set colItems = GetObject("winmgmts:{impersonationLevel=impersonate}!\ > \" _ > * * * * * *& strComputer & "\root\cimv2:Win32_Processor") > col = 2 > rowStart = 2 > > *FillCol(col, rowStart, colItems, objSheet) > > Sub FillCol(col, row1, cItems, oSheet) > > * Dim oItem, oPropertySet, oProperty, y > > * row = row1 > * For Each oItem in cItems > * * Set oPropertySet = oItem.Properties_ > * * For Each oProperty In oPropertySet > * * * objSheet.Cells(col, row).Value = *eval("oItem." & > oProperty.name) > * * * row = row + 1 > * * Next ' Property > * Next ' Item > > End Sub ' FillCol > > This will significantly reduce the number of lines of code, thereby > improving readability, maintenance and reducing the potential for > errors in typing. > > If you have some other particular problem, you'll need to restate your > problem. > > Tom Lavedas > ***********http://there.is.no.more/tglbatch/ that the script will execute "successfully" without giving any errors, but does not actually create or write to the spreadsheet. Running the script gives me an Excel process and obviously a scripting host process. The host process terms after the script has completed, but the Excel process remains, but unfortunately no spreadsheet. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: need help dumping to excel Ugh, I just answered my own question accidentally. Apparently I got sidetracked or distracted. At the end of the script I was missing this: -----/ ' Save the spreadsheet and close the workbook. objExcel.ActiveWorkbook.SaveAs strExcelPath objExcel.ActiveWorkbook.Close ' Quit Excel. objExcel.Application.Quit Wscript.Echo "Done" -----/ Tom, thanks for your help. Now I'll work on using the subroutine you provided. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: need help dumping to excel Tom Lavedas schrieb: Quote: > On Feb 4, 9:46 am, insanity...@xxxxxx wrote: Quote: >> Here's a link to the long script I'm working with: >> >> http://www.gcpsite.com/script.txt >> >> All I'm trying to do is pull information and dump it into a >> spreadsheet, one column per server. I had this script working by >> dumping everything to a text file, but for the purposes of working >> with this data it would be MUCH better in a spreadsheet. The number >> of servers I will be ultimately running this against is just >> impractical to cut/paste from the text file to Excel. Thanks in >> advance for any help. > I'm not certain what your question is, but after taking a very quick > look at the script and doing a brief search of the net, I would offer > the following for consideration: > > First, have a look at this reference ... > > http://www.eggheadcafe.com/software/...r-the-typ.aspx > > Then from it, I created this little subroutine that could be used to > greatly simplify your long lists of cell locations and properties ... > > ' Assuming strComputer and objSheet are defined correctly, for > example ... > ' > Set colItems = GetObject("winmgmts:{impersonationLevel=impersonate}!\ > \" _ > & strComputer & "\root\cimv2:Win32_Processor") > col = 2 > rowStart = 2 > > FillCol(col, rowStart, colItems, objSheet) > > Sub FillCol(col, row1, cItems, oSheet) > > Dim oItem, oPropertySet, oProperty, y > > row = row1 > For Each oItem in cItems > Set oPropertySet = oItem.Properties_ > For Each oProperty In oPropertySet > objSheet.Cells(col, row).Value = eval("oItem." & > oProperty.name) > row = row + 1 > Next ' Property > Next ' Item > > End Sub ' FillCol > > This will significantly reduce the number of lines of code, thereby > improving readability, maintenance and reducing the potential for > errors in typing. > > If you have some other particular problem, you'll need to restate your > problem. > > Tom Lavedas > *********** > http://there.is.no.more/tglbatch/ Dim sServer : sServer = "W2K" Dim oWMI : Set oWMI = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & sServer & "\root\cimv2" ) Dim oCol : Set oCol = oWMI.ExecQuery( "Select * from Win32_BIOS" ) Dim oItem For Each oItem in oCol Dim oProp For Each oProp In oItem.Properties_ On Error Resume Next ' WScript.Echo oProp.Name, Eval( "oItem." & oProp.Name ) WScript.Echo oProp.Name, oProp.Value If 0 <> Err.Number Then WScript.Echo "***", oProp.Name, Err.Description On Error GoTo 0 Next Next to make sure that: (a) The Eval() can be replaced by oProp.Value (b) The more nasty types have to be handled (c) As the OT is interested in specific values (b) can be made easier (perhaps even trivial) by specifying the relevant property names: Dim sServer : sServer = "W2K" Dim oWMI : Set oWMI = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & sServer & "\root\cimv2" ) Dim oCol : Set oCol = oWMI.ExecQuery( "Select * from Win32_BIOS") Dim dicPN : Set dicPN = CreateObject( "Scripting.Dictionary" ) dicPN( "Caption" ) = 0 dicPN( "SerialNumber" ) = 0 ' my SerialNumber is empty dicPN( "ListOfLanguages" ) = 0 ' extra work, if you want this Dim oItem For Each oItem in oCol Dim oProp For Each oProp In oItem.Properties_ If dicPN.Exists( oProp.Name ) Then On Error Resume Next WScript.Echo oProp.Name, oProp.Value If 0 <> Err.Number Then WScript.Echo "***", oProp.Name, Err.Description On Error GoTo 0 End If Next Next output: cscript audit.00.vbs Caption Phoenix-Award BIOS v6.00PG *** ListOfLanguages Typen unverträglich SerialNumber |
My System Specs![]() |
| | #6 (permalink) |
| | Re: need help dumping to excel <insanity2k4@xxxxxx> wrote in message news:642f712b-a9cd-478a-8572-ca0b4af0fa27@xxxxxx On Feb 4, 11:20 am, Tom Lavedas <tglba...@xxxxxx> wrote: Quote: > I'm not certain what your question is, but after taking a very quick > look at the script and doing a brief search of the net, I would offer > the following for consideration: > > First, have a look at this reference ... > > http://www.eggheadcafe.com/software/...-do-i-discover... > > Then from it, I created this little subroutine that could be used to > greatly simplify your long lists of cell locations and properties ... > > ' Assuming strComputer and objSheet are defined correctly, for > example ... > ' > Set colItems = GetObject("winmgmts:{impersonationLevel=impersonate}!\ > \" _ > & strComputer & "\root\cimv2:Win32_Processor") > col = 2 > rowStart = 2 > > FillCol(col, rowStart, colItems, objSheet) > > Sub FillCol(col, row1, cItems, oSheet) > > Dim oItem, oPropertySet, oProperty, y > > row = row1 > For Each oItem in cItems > Set oPropertySet = oItem.Properties_ > For Each oProperty In oPropertySet > objSheet.Cells(col, row).Value = eval("oItem." & > oProperty.name) > row = row + 1 > Next ' Property > Next ' Item > > End Sub ' FillCol > > This will significantly reduce the number of lines of code, thereby > improving readability, maintenance and reducing the potential for > errors in typing. > > If you have some other particular problem, you'll need to restate your > problem. > > Tom Lavedas > ***********http://there.is.no.more/tglbatch/ that the script will execute "successfully" without giving any errors, but does not actually create or write to the spreadsheet. ===> I'm not sure why you equate "not giving any errors" with "running successfully". In my opinion, a script that fails to perform the intended task has not run successfully. /Al Running the script gives me an Excel process and obviously a scripting host process. The host process terms after the script has completed, but the Excel process remains, but unfortunately no spreadsheet. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Help Blue Screen- Dumping Physical Memory! | General Discussion | |||
Vista Ultimate64bit SP1- Dumping Monitor Profile | General Discussion | |||
| Recycle Bin won't stop dumping itself | Vista General | |||
| dumping vista | Vista installation & setup | |||
| Dumping 64-bit version for 32 | Vista General | |||