WSHNetwork

  • Thread starter Thread starter mcnewsxp
  • Start date Start date
Windows Script Host Object Model.

But why do you want it? What are you trying to do? There may be better ways.
 
Windows Script Host Object Model.
But why do you want it? What are you trying to do? There may be better
ways.

not sure.
it's another one of those inherited systems.
i get an error message when i try to complie the code is the only reason.
i'm on a budget and deadline so i don't have time to fish around.
 
not sure.
it's another one of those inherited systems.
i get an error message when i try to complie the code is the only
reason. i'm on a budget and deadline so i don't have time to fish
around.

You can almost always replace a reference (early binding) with late
binding and use Object variable types. Here's an example:


Dim objFSO As Object

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("\\d9m09521\WB\") Then

[etc.]

In that case, I'm able to use the .FolderExists method of the File
System Object without needing to have a reference to it.
 
David W. Fenton said:
not sure.
it's another one of those inherited systems.
i get an error message when i try to complie the code is the only
reason. i'm on a budget and deadline so i don't have time to fish
around.

You can almost always replace a reference (early binding) with late
binding and use Object variable types. Here's an example:


Dim objFSO As Object

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("\\d9m09521\WB\") Then

[etc.]

In that case, I'm able to use the .FolderExists method of the File
System Object without needing to have a reference to it.

Do you happen to know how to late bind WSH David? You need to add a
reference to Windows Script Host Object Model
(C:\Windows\System32\wshom.ocx). That shows up in the Object Browser as
IWshRuntimeLibrary

I would have expected that would result in

Set wshObj = CreateObject("IWshRuntimeLibrary.WSHNetwork")

working, but it doesn't.
 
Douglas J. Steele said:
David W. Fenton said:
Windows Script Host Object Model.

But why do you want it? What are you trying to do? There may be
better ways.

not sure.
it's another one of those inherited systems.
i get an error message when i try to complie the code is the only
reason. i'm on a budget and deadline so i don't have time to fish
around.

You can almost always replace a reference (early binding) with late
binding and use Object variable types. Here's an example:


Dim objFSO As Object

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("\\d9m09521\WB\") Then

[etc.]

In that case, I'm able to use the .FolderExists method of the File
System Object without needing to have a reference to it.

Do you happen to know how to late bind WSH David? You need to add a
reference to Windows Script Host Object Model
(C:\Windows\System32\wshom.ocx). That shows up in the Object Browser
as IWshRuntimeLibrary

I would have expected that would result in

Set wshObj = CreateObject("IWshRuntimeLibrary.WSHNetwork")

working, but it doesn't.

Try through WScript

Set wshObj = CreateObject("WScript.Network")
 
[]
You can almost always replace a reference (early binding) with
late binding and use Object variable types. Here's an example:

Dim objFSO As Object

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("\\d9m09521\WB\") Then

[etc.]

In that case, I'm able to use the .FolderExists method of the
File System Object without needing to have a reference to it.

Do you happen to know how to late bind WSH David?

I assume you've determined that the object I used above does not
represent the whole WSH object model?
You need to add a
reference to Windows Script Host Object Model
(C:\Windows\System32\wshom.ocx). That shows up in the Object
Browser as IWshRuntimeLibrary

I would have expected that would result in

Set wshObj = CreateObject("IWshRuntimeLibrary.WSHNetwork")

working, but it doesn't.

I don't recall where I got the correct reference for using the FSO
with late binding.

Given that the wshom.ocx has the FileSystemObject as one of its
members, I'd think that it's the same thing. But an OCX is intended
to be used as a replacement for doing it directly. My guess would be
that this OCX is just an interface to the same functionality as I'm
getting through the Scripting object. Yes, just browsing the
registry I see that Scripting refers to the scripting functionality
in scrrun.dll. The OCX is a superset of scrrun.dl functionality, but
most of the additional functionality seems to me to be just
additions to make it easier to do things that scrrun.dll does.

OK, I'm wrong in what I say above. The libaries have a lot of
overlap, but are not the same. The OCX has these members:

Drive, Drives, File, Files, FSO, Folder, Folders, TextStream,
WSHCollection, WSHEnvironment, WSHExec, WSHNetwork, WSHShell,
SWHShortcut, SWHURLShortcut

while the DLL adds Dictionary and Encoder, but lacks all the WSH
members.

However, the WSH members all seem to me to be for controlling the
WSH, rather than for implementing functionality offered by the WSH's
object model. That is, the WSH members are for getting to
functionality that doesn't have its own top-level object. I don't
know enough about the WSH to know what those would be.
 
Back
Top