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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping A Network Drive on Client PC 1

Status
Not open for further replies.

iyarosh

Programmer
Apr 14, 2003
49
US
Hello All,

I'm trying to map client PC to a remote drive using ASP. The idea is when the user launches asp web page the drive gets mapped to user's computer if not already mapped. I've seen all the posts in this forum and tried many of the suggestions, but the best I could get to is to map the drive to the server. Any help would be greatly appreciated.
Here is the final version of my code that does not do anything:
Code:
<%@ Language=VBScript %>
<%Option Explicit%>
<%
Dim objNetwork
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive "Z:"
objNetwork.MapNetworkDrive "Z:","\\nymf1\dbm"
WScript.Quit
%>
 
Convert that to client side vbscript and it will work. As long as this is on your network


General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Onpnt,

Thank you for your responce. I know that the conversion of this script to a client side is something very simple for anyone who knows ASP or VBScript, but unfortunately, I'm not familiar with the language and this is something I need to take care of one time. Could please help me with the conversion or show the way to convert by a sample?

Thank you,
Igor.
 
Most of the time when you use vbscript for the language in ASP the scripts are interchangable with client versions. Some slight changes need to be made to objects created via server/client etc.. In that being said just about any scripting language can be quickly changed to client side (javascript, python etc...) with a simple task of removing the server side scripting tag references.

So in your case
Code:
<%@ Language=VBScript %>
<%Option Explicit%>
<%
Dim objNetwork
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive "Z:"
objNetwork.MapNetworkDrive "Z:","\\nymf1\dbm"
WScript.Quit
%>

would easily become a .vbs file by doing the following
Code:
Option Explicit
Dim objNetwork
On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive "Z:"
objNetwork.MapNetworkDrive "Z:","\\nymf1\dbm"
WScript.Quit

In that being said be warned on the line
objNetwork.RemoveNetworkDrive "Z:"

Unless there is a current network connection of Z: mapped you will get an error (if you comment out the On Error Resume...). If you are going to use vbscript's error handling I would look into catching the errors that may or may not occur.

So to make that look a bit cleaner something as

Code:
Option Explicit

Dim objNetwork

On Error Resume Next

Set objNetwork = CreateObject("Wscript.Network")
objNetwork.RemoveNetworkDrive "Z:"
objNetwork.MapNetworkDrive "Z:","\\nymf1\dbm"

If Err.Number <> 0 Then  
	Wscript.Echo "An exception was found.  Error Number: " & Err.Number
	Err.Clear
End If

WScript.Quit

I would go to jscript on the next step. The error handling is far better over vbscript. As you will see from the error generated from a Z Drive not being found.

Further discussion please refer to forum329 (vbscript forum) as that will be the best palce for it.


General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
I'm afraid my expertice in this matter is not sufficient to use this suggestion. That script works perfectly as .vbs, but I'm trying to put the code inside of the html page that I'll convert into asp and have no idea how and what tags to use. Would you be able to show me how to put it inside .asp file and make it work for the client. I highly appreciate your time.
 
enclose the script in

<script language="vbscript">

</script>

so run it in a web page


General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Onpnt,
Thank you so much; that worked exactly as I needed.

One more questions, is there a way to disable ActiveX warning message that comes up when the page is launched other than go to IE properties manually?

I highly appreciate your help! Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top