Jump to content

Find out what software is installed on a pc script


Recommended Posts

Posted

Ive got this scrpit:

 

WScript.Echo InstalledApplications(".")

Function InstalledApplications(node)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oRegistry = GetObject("winmgmts://" _
 & node & "/root/default:StdRegProv")
sBaseKey = _
 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)

For Each sKey In arSubKeys

 iRC = oRegistry.GetStringValue( _
  HKLM, sBaseKey & sKey, "DisplayName", sValue)
 If iRC <> 0 Then
  oRegistry.GetStringValue _
   HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
 End If
 If sValue <> "" Then
  InstalledApplications = _
   InstalledApplications & sValue & vbCrLf
 End If
Next

End Function

 

it shows the user what software is installed on the local machine, but im wanting to output it to a text file

 

Can someone tell me how to do it please

 

Thanks

 

T

Posted

If it were C i could have a stab at saying something to do with

 

FILE *out;

 

fopen(some stuffs i'd need to look up);

fprintf(some more stuffs i'd need to look up);

fclosef(yet more stuffs i'd need to look up);

 

Have a look on t'internet for streams.

 

If it's just for running occassionally on one machine try http://www.belarc.com

 

It'll list all your machine specs, all the software, all the windows patches etc etc into a local HTML file.

 

Very useful.

Posted

As you arer coding in VBS you can make use of the FileSystemObject as in this example from the MS scripting docs:

 

' VBScript
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close

 

In your script you would use something like

OutputFile.WriteLine (InstalledApplications("."))

rather than script echo.

 

Alternatively why not just pipe the output to a file

 csript Installed_Software.vbs > OutputFile.Txt

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...