Convert VBScript to Batch File

Posted on 2012-03-23
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,


Public Sub SoftwareInformationVBS(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String)   
        Dim objWMIService, objFSO, objTextFile, colSoftware, objSoftware, objSWbemLocator   
            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")   
                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 & _   
        Catch ex As Exception   
        End Try  
End Sub  

Open in new window

Question by:ReneGe
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 55

Accepted Solution

Bill Prew earned 500 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

LVL 10

Author Comment

ID: 37758817
And why didn't I think of this one??
Thanks Bill!!
LVL 55

Expert Comment

by:Bill Prew
ID: 37758845

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

695 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