Board index » Visual Studio » HELP SOFTWARE INVENTORY SCRIPT

HELP SOFTWARE INVENTORY SCRIPT

Visual Studio188
Hi,



I am new to this scripting thing, and I am sure this has been explored many

a time, however I have not been able to find something that does exactly want

I want



I am currently writing a script to inventory all installed software that

shows up in th e control panel (no matter what the method, windows installer

or not). I have it creating a text file with all the output being piped to

it. The only problem is that at the moment I have additional blank lines

showing up in the outputted file. I dont want these additional blank lines,

but just the lines with the information.



Can someone out there be so kind, and help this poor soul ;)



TIA

Eric



I have attached the script below







Set objFSO = CreateObject("Scripting.FileSystemObject")

' Allows creation of Files



Set objNetwork = CreateObject("Wscript.Network")

' Allows accessing network variables





Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

' reg access







strComputerName = objNetwork.ComputerName

' Store the computer names as a variable strComputer



strPath = "c:\scripts\"

' Folder where the completed file will be saved

' Needs to be a local or UNC path





' Soft Inventory portion

strComputer = "."

'



strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

strEntry1a = "DisplayName"

strEntry1b = "QuietDisplayName"

strEntry2 = "InstallDate"

strEntry3 = "VersionMajor"

strEntry4 = "VersionMinor"

' Inventory these keys







' <----- Actual Script

strFullName = objFSO.BuildPath(strPath, strComputerName)

Set objTextFile = objFSO.CreateTextFile(strFullName & ".tsv", True)

' Creates a TSV file with a file name of computer it is being run on





objTextFile.WriteLine "Name" & vbtab & _

"Install Date" & vbtab & _

"Version"





' soft inventory portion

Set objReg = GetObject("winmgmts://" & strComputer &

"/root/default:StdRegProv")

objReg.EnumKey HKLM, strKey, arrSubkeys







For Each strSubkey In arrSubkeys

intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a,

strValue1)

If intRet1 <>0 Then

objReg.GetStringValue HKLM, strKey & strSubkey, trEntry1b, strValue1

End If

If strValue1 <>"" Then

End If



objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2

If strValue2 <>"" Then

End If



objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3

objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry4, intValue4

If intValue3 <>"" Then

End If



objTextFile.WriteLine strValue1 & vbtab & strValue2 & vbtab & intValue3 &

"." & intValue4



Next



objTextFile.Close

WScript.Quit


-
 

Re:HELP SOFTWARE INVENTORY SCRIPT

Just for clarification:

Are you running this script against all of the computers on your network?

If so, is it possible the blank lines are computers that are unreachable

from the workstation you are running the script on?



C.





"Eric" <Eric@discussions.microsoft.com>wrote in message

Quote
Hi,



I am new to this scripting thing, and I am sure this has been explored

many

a time, however I have not been able to find something that does exactly

want

I want



I am currently writing a script to inventory all installed software that

shows up in th e control panel (no matter what the method, windows

installer

or not). I have it creating a text file with all the output being piped to

it. The only problem is that at the moment I have additional blank lines

showing up in the outputted file. I dont want these additional blank

lines,

but just the lines with the information.



Can someone out there be so kind, and help this poor soul ;)



TIA

Eric



I have attached the script below







Set objFSO = CreateObject("Scripting.FileSystemObject")

' Allows creation of Files



Set objNetwork = CreateObject("Wscript.Network")

' Allows accessing network variables





Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

' reg access







strComputerName = objNetwork.ComputerName

' Store the computer names as a variable strComputer



strPath = "c:\scripts\"

' Folder where the completed file will be saved

' Needs to be a local or UNC path





' Soft Inventory portion

strComputer = "."

'



strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

strEntry1a = "DisplayName"

strEntry1b = "QuietDisplayName"

strEntry2 = "InstallDate"

strEntry3 = "VersionMajor"

strEntry4 = "VersionMinor"

' Inventory these keys







' <----- Actual Script

strFullName = objFSO.BuildPath(strPath, strComputerName)

Set objTextFile = objFSO.CreateTextFile(strFullName & ".tsv", True)

' Creates a TSV file with a file name of computer it is being run on





objTextFile.WriteLine "Name" & vbtab & _

"Install Date" & vbtab & _

"Version"





' soft inventory portion

Set objReg = GetObject("winmgmts://" & strComputer &

"/root/default:StdRegProv")

objReg.EnumKey HKLM, strKey, arrSubkeys







For Each strSubkey In arrSubkeys

intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a,

strValue1)

If intRet1 <>0 Then

objReg.GetStringValue HKLM, strKey & strSubkey, trEntry1b, strValue1

End If

If strValue1 <>"" Then

End If



objReg.GetStringValue HKLM, strKey & strSubkey, strEntry2, strValue2

If strValue2 <>"" Then

End If



objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3

objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry4, intValue4

If intValue3 <>"" Then

End If



objTextFile.WriteLine strValue1 & vbtab & strValue2 & vbtab & intValue3 &

"." & intValue4



Next



objTextFile.Close

WScript.Quit





-

Re:HELP SOFTWARE INVENTORY SCRIPT

Hi, Thanks for writing back



At the moment the script is only being run on a single machine in a local

context.



I plan to eventually include it in my login scripts but I am not at that

stage yet, but it should still run in a local machine context.



Cheers!



Eric



"CJH" wrote:



Quote
Just for clarification:

Are you running this script against all of the computers on your network?

If so, is it possible the blank lines are computers that are unreachable

from the workstation you are running the script on?



C.





"Eric" <Eric@discussions.microsoft.com>wrote in message

news:27284B19-BCBF-4684-BCDC-7B0049B553D2@microsoft.com...

>Hi,

>

>I am new to this scripting thing, and I am sure this has been explored





<snip>

-

Re:HELP SOFTWARE INVENTORY SCRIPT

No prob.

So the blank lines are occuring even though you are running it on just a

local machine?



"Eric" <Eric@discussions.microsoft.com>wrote in message

Quote
Hi, Thanks for writing back



At the moment the script is only being run on a single machine in a local

context.



I plan to eventually include it in my login scripts but I am not at that

stage yet, but it should still run in a local machine context.



Cheers!



Eric



"CJH" wrote:



>Just for clarification:

>Are you running this script against all of the computers on your network?

>If so, is it possible the blank lines are computers that are unreachable

>from the workstation you are running the script on?

>

>C.

>

>

>"Eric" <Eric@discussions.microsoft.com>wrote in message

>news:27284B19-BCBF-4684-BCDC-7B0049B553D2@microsoft.com...

>>Hi,

>>

>>I am new to this scripting thing, and I am sure this has been explored





<snip>





-

Re:HELP SOFTWARE INVENTORY SCRIPT

Hi Again



Yes this is still happening even when run on one local machine.

I find it a headscratcher.



Eric



"CJH" wrote:



Quote
No prob.

So the blank lines are occuring even though you are running it on just a

local machine?



"Eric" <Eric@discussions.microsoft.com>wrote in message

news:1C3A7E35-D292-4E91-8B10-6F9F3EE11994@microsoft.com...

>Hi, Thanks for writing back

>

>At the moment the script is only being run on a single machine in a local

>context.

>

>I plan to eventually include it in my login scripts but I am not at that

>stage yet, but it should still run in a local machine context.

>

>Cheers!

>

>Eric

>

>"CJH" wrote:

>

>>Just for clarification:

>>Are you running this script against all of the computers on your network?

>>If so, is it possible the blank lines are computers that are unreachable

>>from the workstation you are running the script on?

>>

>>C.

>>

>>

>>"Eric" <Eric@discussions.microsoft.com>wrote in message

>>news:27284B19-BCBF-4684-BCDC-7B0049B553D2@microsoft.com...

>>>Hi,

>>>

>>>I am new to this scripting thing, and I am sure this has been explored

>

>

><snip>







-