Click here to Skip to main content
15,887,957 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i have a vbs code that give me a result and i want to use this vbs code into visual basic programme
what i have try :

1- convert vbs code into dll (failed)

so my question is how to execute the vbs code and get result and use it in visual basic program
Posted
Updated 19-Jan-16 9:47am
v2
Comments
Maciej Los 19-Jan-16 15:43pm    
Not a question at all!

1 solution

I would have thought the simplest approach was to simply re-write the vbs in visual basic (do you mean VB.Net) - it cant be that hard, surely .. for sure, if you wanted to make things complex for little gain, you could use the WSH COM object from within VB.Net for example to run the vbs, it really depends on your requirements as to wether its worth the effort - for a 'one-off' no way, for a larger extensible system, 'maybe'

'g'
 
Share this answer
 
Comments
Member 12164472 19-Jan-16 19:37pm    
well this is my code

set args = Wscript.Arguments
If Wscript.Arguments.Count = 0 Then
strComputer = "."
Else
strComputer = args.item(0)
end if

'Query WMI
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PnPSignedDriver")
'Output to console
For Each objItem in colItems
dim strLine
strLine = objItem.FriendlyName
If InStr(1,strLine,"camera",1) > 0 Then WScript.Echo objItem.FriendlyName End If
If InStr(1,strLine,"microphone",1) > 0 Then WScript.Echo objItem.FriendlyName End If
Next
i want to make this in visual basic all the idea was that it would be very easy to use the script as dill or even the script it self can you convert it :D
Member 12164472 19-Jan-16 20:39pm    
here is my code in visual studio
Dim strComputer = "."
Dim objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Dim colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PnPSignedDriver ")
'Output to console
For Each objItem In colItems
Dim strLine As String
strLine = objItem.FriendlyName.ToString
Dim camera As String
camera = "Camera"
If strLine.Contains(camera) Then
MsgBox(strLine)

End If
Next
Dim strComputer1 = "."
Dim objWMIService1 = GetObject("winmgmts:\\" & strComputer1 & "\root\CIMV2")
Dim colItems1 = objWMIService1.ExecQuery( _
"SELECT * FROM Win32_PnPSignedDriver ")
'Output to console
For Each objItem In colItems1
Dim strLine1 As String
strLine1 = objItem.FriendlyName.ToString
Dim mic As String
mic = "Microphone"
If strLine1.Contains(mic) Then
MsgBox(strLine1)
End If
Member 12164472 19-Jan-16 20:40pm    
the problem is in f strLine1.Contains(mic) Then contain here is case sensitive this is a big problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900