473,698 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CreateObject("W Script.Network" )

I use the below code to get the Network Places items. However, this requires
"Late Binding". I read that you can avoid late binding by adding a reference
to the Com Types in your application. Does anyone know what reference to add
and what to import?

Dim drives() As String
Dim ob As Object = CreateObject("W Script.Network" )
Dim odrives As Object = ob.EnumNetworkD rives
dim k as integer
If odrives.count > 0 Then
ReDim drives(CInt(odr ives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToL ower
Next
End If
--
Dennis in Houston
Nov 21 '05 #1
1 22592
Never mind...I've got it figured out:

Imports IWshRuntimeLibr ary

Dim drives() As String
Dim o As IWshNetwork2 = CType(CreateObj ect("WScript.Ne twork"), IWshNetwork2)
Dim odrives As WshCollection = CType(o.EnumNet workDrives, WshCollection)
If odrives.count > 0 Then
ReDim drives(CInt(odr ives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToL ower
Next
End If

"Dennis" wrote:
I use the below code to get the Network Places items. However, this requires
"Late Binding". I read that you can avoid late binding by adding a reference
to the Com Types in your application. Does anyone know what reference to add
and what to import?

Dim drives() As String
Dim ob As Object = CreateObject("W Script.Network" )
Dim odrives As Object = ob.EnumNetworkD rives
dim k as integer
If odrives.count > 0 Then
ReDim drives(CInt(odr ives.Count / 2))
For i = 0 To odrives.Count - 1 Step 2
k = k + 1
drives(k) = odrives.Item(i + 1).ToString.ToL ower
Next
End If
--
Dennis in Houston

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
50582
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork = WScript.CreateObject("WScript.Network") sPwd = inputbox("Enter password") WshNetwork.MapNetworkDrive "J:", "\\server1\data", false, "xyz_net\John", sPwd Msgbox "Drives has been map successful"
5
24141
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and I'm not sure what changed. (I had applied ALL the W2K update patches... but... I'm not sure if the problem started before or after that.) Did any recent W2K patches change the way createObject, wScript.shell, or "NET SEND" works?
3
19159
by: Yitzhak | last post by:
I am having "Permission denied" error while calling LogEvent method of WScript.Shell component. Basically, ASP page calls Windows Script Host Shell component to log events to the OS Application Event log. My environment: Windows Server 2003, IIS 6, WSH, Classic ASP, Vbscript Below is the code and the error: Code:
2
19274
by: Mike John | last post by:
I am trying to use the shell object to send keys to the explorer browser to run the send page funcion. I am receiving the above error only when I put my html file in the web server folder.However if I am runing the file local it will work Any reason, why when the file is in the web server folder the create object failed to created the shell object. Systax:
5
1511
by: Nick Gilbert | last post by:
Hi, I recently upgraded a website from ASP.NET 1.1 to 2.0. While working on the site and changing aspx or ascx files, I sometimes randomly get a compilation error after refreshing the page in the browser (NOT when building the project from within VS.NET). The only way to fix it is to clean the project and rebuild it - then reload the page again. This behaviour is very annoying and I can't work out what's causing it. None of my other...
3
3380
by: radrain | last post by:
Unable to CreateObject("wscript.network") in IE7. This works fine in IE6 BUT this is now considered to be 'unsafe' and I cannot find any alternatives to getting the computer name and the UserDomain. Any suggestions? Richard
3
7632
by: =?Utf-8?B?VG9kZA==?= | last post by:
trying to access files located on another server within the network. the folder is shared out and we created a virtual directory as well. The error is Microsoft VBScript runtime error '800a004c' Path not found Here is my code <% dim fs,fo,x set fs=Server.CreateObject("Scripting.FileSystemObject")
0
2690
by: edurran | last post by:
Hi all, I have spent the last three days on this problem. Looked in many forums and not found the answer as yet. Hopefully ye can help. I have two functions. One works fine, the second does not. First Function Function try1 SET objShell = CreateObject("Wscript.Shell")
2
5564
by: moodyman13 | last post by:
Hi all, Hoping someone can help me. I'm using WSH to automatically map a network drive when someone opens a webpage. Below are the codes <HTML> <Body> <script language="VBScript" type="text/vbscript"> Option Explicit On Error Resume Next
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.