Passing WHS value to VB 
Author Message
 Passing WHS value to VB

I am looking to use windows system variable acquired by a WSHcript
( WshEnvironment like "WINDIR"  or WshNetwork like Username  )
in a Visual Basic program.

Can anyone help me ???



Sat, 17 Apr 2004 04:43:35 GMT  
 Passing WHS value to VB
A VB program can create instances of the "WScript.Shell" and "WScript.Network" objects.  In VB, you can even early bind.  

To early bind, add a project reference to "Windows Script Host Object Model" (wshom.ocx).

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I am looking to use windows system variable acquired by a WSHcript
> ( WshEnvironment like "WINDIR"  or WshNetwork like Username  )
> in a visual basic program.

> Can anyone help me ???



Sat, 17 Apr 2004 05:12:33 GMT  
 Passing WHS value to VB
Can you give me an exemple to how can I create an instances in VB ?

thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sat, 17 Apr 2004 21:51:15 GMT  
 Passing WHS value to VB
Private Sub Command1_Click()
Set sll = CreateObject("wscript.shell")
x = sll.expandEnvironmentStrings("%windir%")
MsgBox x
End Sub

Late bound case. Anyway, isnt there VB newsgroup?


Quote:
> Can you give me an exemple to how can I create an instances in VB ?

> thanks

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sat, 17 Apr 2004 22:45:20 GMT  
 Passing WHS value to VB
Early bound VB/VBA (project reference to wshom.ocx required)...

Dim WshShell As WshShell
Set WshShell = New IWshRuntimeLibrary.WshShell

Dim WshNetwork As IWshRuntimeLibrary.WshNetwork
Set WshNetwork = New IWshRuntimeLibrary.WshNetwork

(Note that the "IWshRuntimeLibrary." qualifier is not strictly required in this case.)

Late bound VB/VBA ...

Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")

Dim WshNetwork As Object
Set WshNetwork = CreateObject("WScript.Network")

(Note that "...As Variant" will work too, but "...As Object is more efficient.)

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> Can you give me an exemple to how can I create an instances in VB ?

> thanks

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sun, 18 Apr 2004 01:12:51 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Passing values by reference from java / vb script to ActiveX object

2. vb passing values to html

3. Pass Session value to a VB Sub

4. Passing values by reference from java / vb script to ActiveX object

5. Passing Value to VB Script

6. Passing a Wsh value to VB

7. How can pass a value from Vb script to java script

8. showModalDialog: Passing multiple values back from child

9. Passing form values

10. Pass form values to third party form?

11. How to pass value from server to client

12. Problem of Passing value from .asp to .vbs

 

 
Powered by phpBB® Forum Software