Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert VBScript to Batch File

Posted on 2012-03-23
3
Medium Priority
?
845 Views
Last Modified: 2012-03-23
Hi there,

I need to convert the following script that I think is VBScript, to a Batch File.

Thanks for your help,
Rene

SOURCE: http://codesnippts.blogspot.ca/2010/07/public-sub-softwareinformationvbsbyval.html

Public Sub SoftwareInformationVBS(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String)   
  
        Dim objWMIService, objFSO, objTextFile, colSoftware, objSoftware, objSWbemLocator   
  
        Try  
  
            objFSO = CreateObject("Scripting.FileSystemObject")   
            objTextFile = objFSO.CreateTextFile("c:\software.txt", True)   
  
            objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")   
  
            If (strComputer = Environment.MachineName.ToString) Then  
  
                objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2")   
            Else  
                objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUserName, strPwd)   
            End If  
  
            objWMIService.Security_.ImpersonationLevel = 3   
  
            colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")   
            objTextFile.WriteLine("Caption" & vbTab & _   
                "Description" & vbTab & "Identifying Number" & vbTab & _   
                "Install Date" & vbTab & "Install Location" & vbTab & _   
                "Install State" & vbTab & "Name" & vbTab & _   
                "Package Cache" & vbTab & "SKU Number" & vbTab & "Vendor" & vbTab _   
                    & "Version")   
            For Each objSoftware In colSoftware   
                objTextFile.WriteLine(objSoftware.Caption & vbTab & _   
                objSoftware.Description & vbTab & _   
                objSoftware.IdentifyingNumber & vbTab & _   
                objSoftware.InstallDate2 & vbTab & _   
                objSoftware.InstallLocation & vbTab & _   
                objSoftware.InstallState & vbTab & _   
                objSoftware.Name & vbTab & _   
                objSoftware.PackageCache & vbTab & _   
                objSoftware.SKUNumber & vbTab & _   
                objSoftware.Vendor & vbTab & _   
                objSoftware.Version)   
            Next  
            objTextFile.Close()   
  
        Catch ex As Exception   
  
        End Try  
           
End Sub  

Open in new window

0
Comment
Question by:ReneGe
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 37758776
How about this?
wmic product get Caption,Description,IdentifyingNumber,InstallDate2,InstallLocation,InstallState,Name,PackageCache,SKUNumber,Vendor,Version /format:csv >c:\software.txt

Open in new window

~bp
0
 
LVL 10

Author Comment

by:ReneGe
ID: 37758817
And why didn't I think of this one??
Thanks Bill!!
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 37758845
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question