home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2723
Discussions: 188,384, Posts: 2,243,508, Members: 232,615
Old January 30th, 2003, 02:16 AM   Digg it!   #1 (permalink)
Member
 
nishark's Avatar
 
Join Date: Aug 2002
Location: Downunder
Posts: 432
resolving network paths

I'm trying to store the full network path of a file in a shared directory
network into a database, so that other users using the same database can
call up this document from anywhere in the network.

for example
Mapped location on local system: L:\Subdirectory\Disaster.doc
Network location: \\NetworkFileServer\ITDATA\Disaster.doc

I have a form where the user browses the local file system to 'upload'. My aim is to get this location and map it to the corresponding network path location. Then store the network path in the database.

in this case, if a user decides to upload 'Disaster.doc' from his/her L: drive, the network location of the file i.e. "\\NetworkFileServer\ITDATA\Disaster.doc" is stored in the database.

How do I get this corresponding network location?

I'll be using JSP/Javascript, but dont hesitate to present solutions using anything else.

nishark is offline   Reply With Quote
Old January 31st, 2003, 12:47 AM     #2 (permalink)
Member
 
nishark's Avatar
 
Join Date: Aug 2002
Location: Downunder
Posts: 432
The following does the trick:


<HTML>
<HEAD>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
function displayNetworkShares() {
var WshNetwork = new ActiveXObject("WScript.Network");
var Drives = WshNetwork.EnumNetworkDrives()
var DriveInfo = new Array()
var j = 0

var content = "<h1>Drive Mapping List</h1>"
for (i = 0; i < Drives.length; i++) {
content += "<p>" + Drives.Item(i) + "</p>"
}
document.write(content)
}
</SCRIPT>

</HEAD>
<BODY>
<form>
<input type="Button" name="Button1" value="Give list" onClick="displayNetworkShares()">
</form>
</body>
</html>


please let me know if you notice any apparent errors or problems.

i'd really appreciate if people who have mapped network drives would please cut n paste this code and save it as a '.html' file, open it using IE and let me know what happened.

also, is there anyway of doing the same thing in Netscape/other browsers???

nishark is offline   Reply With Quote
Old March 1st, 2003, 08:20 PM     #3 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,019
yep it works.. the user will get a warning about accessing an activex control though.

Other browsers won't support activex controls so unless they had an exe possibly no w/o some form of interpreter installed locally like Perl (that I know of at least)

vass0922 is offline   Reply With Quote
Old March 3rd, 2003, 08:17 AM     #4 (permalink)
Member
 
nishark's Avatar
 
Join Date: Aug 2002
Location: Downunder
Posts: 432
phew!!
thanks for replying vass...
i already delivered the product anyways
nishark is offline   Reply With Quote
Old March 3rd, 2003, 08:28 AM     #5 (permalink)
Retired mostly.
 
Join Date: Oct 2001
Location: Finland
Posts: 5,143
That's amazing.
-M

//edit:
Is there a site that explains how to do these things with js?

Last edited by muno : March 3rd, 2003 at 08:34 AM.
muno is offline   Reply With Quote
Old March 3rd, 2003, 08:53 AM     #6 (permalink)
Member
 
nishark's Avatar
 
Join Date: Aug 2002
Location: Downunder
Posts: 432
http://www.winguides.com/scripting/r...php?category=3

try that...
in there js == JScript
if u mean js == javascript, and if u know javascript, u should be able to mould the JScript or VB code for ur own purposes...
nishark is offline   Reply With Quote
Old March 3rd, 2003, 10:37 PM     #7 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,019
for jscript the objects are the same as vbscript, so should just have to adapt it for JS
vass0922 is offline   Reply With Quote
Old March 4th, 2003, 03:21 AM     #8 (permalink)
Retired mostly.
 
Join Date: Oct 2001
Location: Finland
Posts: 5,143
I tried looking at that site but it didn't have any tutorials to do stuff like you just did.

I know js a little, but not enough to understand what you did.
-M
muno is offline   Reply With Quote
Old March 4th, 2003, 04:01 AM     #9 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,019
Try a google search on
wscript.network jscript tutorial

I'm not familiar with JS, I know more vbs and the two are essentially the same with the methods and properties they call.. only difference is the obvious syntax. So if you see something done in vbs you maybe able to mold it into JS for your purposes... and if not just ask
vass0922 is offline   Reply With Quote
Old March 4th, 2003, 07:53 AM     #10 (permalink)
Member
 
nishark's Avatar
 
Join Date: Aug 2002
Location: Downunder
Posts: 432
Quote:
Originally posted by muno

I know js a little, but not enough to understand what you did.
-M
well, i had one heck of a time trying to find a tutorial about this. firstly it was very hard to identify what exactly i was looking, tried googling, forums, without much luck. then i stumbled upon this
http://www.civilsolutions.com.au/pub...getuncpath.htm
but this happened to be in foxtalk.....beats me...but then the explanation gave me ideas and i found the wshScript thingy.

then i found the winguides site that i linked in one of the previous posts... that explained the 'EnumNetworkDrives()' method...

frankly, dunno where a readymade tutorial is...
u can use the code that i pasted in one of the previous posts to map network drives to their shares. then store them in two different arrays and manipulate the arrays accordingly i suppose....

do let us know if u find any tutes...
i might just write one if i get time

Last edited by nishark : March 4th, 2003 at 07:59 AM.
nishark is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2896)
CPU wont boot (6)
3-days in and no threads about Gaza (160)
The United States Debt (20)
I think I just killed my computer w.. (24)
hp compaq nc6000 problems (139)
Upgrading RAM (5)
Folderchat Weekday thread (442)
Antec 300 bulk purchase? (11)
Recent Discussions
CPU wont boot (6)
GLaDOS is up. (3)
HP notebook reinstall Vista NO .. (5)
Building a gaming computer advi.. (4)
hp compaq nc6000 problems (139)
Folderchat Weekday thread (442)
Creative T-3000 Subwoofer (3)
ACPI controller halt on boot (2)
Worth the upgrade?? (15)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 10:24 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28