Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert from vbscript to VB6 1

Status
Not open for further replies.

ASPVBNerd

Programmer
Nov 23, 2005
83
SE
I would like to to this with VB6 is it possible?

VBSCRIPT
Code:
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems

        strOS = objOperatingSystem.Caption
        Wscript.Echo strOS 
    
Next
 
Simply replace this:
Wscript.Echo strOS
with this:
MsgBox strOS

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you PHV, I thought that if I would like run it with VB that i had to add a preference.
 
With all this information I get information from another computer.
Code:
Sub ListOSProperties( strComputer )
    Dim objWMIService, colItems

	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
	For Each objItem in colItems
	    Wscript.Echo "BootDevice: " & objItem.BootDevice
	    Wscript.Echo "BuildNumber: " & objItem.BuildNumber
	    Wscript.Echo "BuildType: " & objItem.BuildType
	    Wscript.Echo "Caption: " & objItem.Caption
	    Wscript.Echo "CodeSet: " & objItem.CodeSet
	    Wscript.Echo "CountryCode: " & objItem.CountryCode
	    Wscript.Echo "CreationClassName: " & objItem.CreationClassName
	    Wscript.Echo "CSCreationClassName: " & objItem.CSCreationClassName
	    Wscript.Echo "CSDVersion: " & objItem.CSDVersion
	    Wscript.Echo "CSName: " & objItem.CSName
	    Wscript.Echo "CurrentTimeZone: " & objItem.CurrentTimeZone
	    Wscript.Echo "Debug: " & objItem.Debug
	    Wscript.Echo "Description: " & objItem.Description
	    Wscript.Echo "Distributed: " & objItem.Distributed
	    Wscript.Echo "ForegroundApplicationBoost: " & objItem.ForegroundApplicationBoost
	    Wscript.Echo "FreePhysicalMemory: " & objItem.FreePhysicalMemory
	    Wscript.Echo "FreeSpaceInPagingFiles: " & objItem.FreeSpaceInPagingFiles
	    Wscript.Echo "FreeVirtualMemory: " & objItem.FreeVirtualMemory
	    Wscript.Echo "InstallDate: " & objItem.InstallDate
	    Wscript.Echo "LastBootUpTime: " & objItem.LastBootUpTime
	    Wscript.Echo "LocalDateTime: " & objItem.LocalDateTime
	    Wscript.Echo "Locale: " & objItem.Locale
	    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
	    Wscript.Echo "MaxNumberOfProcesses: " & objItem.MaxNumberOfProcesses
	    Wscript.Echo "MaxProcessMemorySize: " & objItem.MaxProcessMemorySize
	    Wscript.Echo "Name: " & objItem.Name
	    Wscript.Echo "NumberOfLicensedUsers: " & objItem.NumberOfLicensedUsers
	    Wscript.Echo "NumberOfProcesses: " & objItem.NumberOfProcesses
	    Wscript.Echo "NumberOfUsers: " & objItem.NumberOfUsers
	    Wscript.Echo "Organization: " & objItem.Organization
	    Wscript.Echo "OSLanguage: " & objItem.OSLanguage
	    Wscript.Echo "OSProductSuite: " & objItem.OSProductSuite
	    Wscript.Echo "OSType: " & objItem.OSType
	    Wscript.Echo "OtherTypeDescription: " & objItem.OtherTypeDescription
	    Wscript.Echo "PlusProductID: " & objItem.PlusProductID
	    Wscript.Echo "PlusVersionNumber: " & objItem.PlusVersionNumber
	    Wscript.Echo "Primary: " & objItem.Primary
	    Wscript.Echo "QuantumLength: " & objItem.QuantumLength
	    Wscript.Echo "QuantumType: " & objItem.QuantumType
	    Wscript.Echo "RegisteredUser: " & objItem.RegisteredUser
	    Wscript.Echo "SerialNumber: " & objItem.SerialNumber
	    Wscript.Echo "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion
	    Wscript.Echo "ServicePackMinorVersion: " & objItem.ServicePackMinorVersion
	    Wscript.Echo "SizeStoredInPagingFiles: " & objItem.SizeStoredInPagingFiles
	    Wscript.Echo "Status: " & objItem.Status
	    Wscript.Echo "SystemDevice: " & objItem.SystemDevice
	    Wscript.Echo "SystemDirectory: " & objItem.SystemDirectory
	    Wscript.Echo "TotalSwapSpaceSize: " & objItem.TotalSwapSpaceSize
	    Wscript.Echo "TotalVirtualMemorySize: " & objItem.TotalVirtualMemorySize
	    Wscript.Echo "TotalVisibleMemorySize: " & objItem.TotalVisibleMemorySize
	    Wscript.Echo "Version: " & objItem.Version
	    Wscript.Echo "WindowsDirectory: " & objItem.WindowsDirectory
	Next

End Sub


I also kneed to get the IP-address is it possible?


George
 
ASPVBNerd said:
I also kneed to get the IP-address is it possible?
You'll have to convert the following code from Visual FoxPro and if you want both internal and external IP addresses, remove
Code:
 ;
[tab][tab][tab]AND laIPAddress[1] # [192.168.0.1]
'?' will display the result on screen
Code:
lcComputer = [localhost]
loService = GETOBJECT([winmgmts://] 	;
	+ lcComputer 			;
	+ [/root/cimv2])
	
loCards = loService.InstancesOf([Win32_NetworkAdapterConfiguration])
	
FOR EACH loCard in loCards
[tab]laIPAddress = loCard.IPAddress
[tab]IF TYPE("laIPAddress[1]") = [C] ;
[tab][tab][tab]AND OCCURS([.],laIPAddress[1]) = 3 ;
[tab][tab][tab]AND laIPAddress[1] # [0.0.0.0] ;
[tab][tab][tab]AND laIPAddress[1] # [192.168.0.1]
[tab][tab]? laIPAddress[1]
[tab]ENDI
NEXT


FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 
A starting point:
For Each I In GetObject("winmgmts:\\" & strComputer & "\root\CIMV2").ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True")
MsgBox "IP=" & I.IPAddress(0) & vbCrLf & "GW=" & I.DefaultIPGateway(0)
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top