Solved

Convert VBScript to Batch File

Posted on 2012-03-23
3
836 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
[X]
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
3 Comments
 
LVL 55

Accepted Solution

by:
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

~bp
0
 
LVL 10

Author Comment

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

Expert Comment

by:Bill Prew
ID: 37758845
:-)
0

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  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) 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