mapping network drive

title says it all

mapping network drive

Postby dalanik on Mon Mar 05, 2007 9:55 pm

I dunno if this would be interesting to anyone, but I had this problem for a long time, since I use a network drive for movies.

The thing is, that sometimes, if I turn on HTPC and the NetDrive remains off, and I turn it on AFTER HTPC boots, it still sees network drive as offline. Connected, but offline. And if you ask why would I use drive instead of UNC path, it's ismply because then I can open movies from Zoom. If I used UNC path, there's no way to open files from Zoom's navigator.

Anyway, for a long time I used this script which simply maps drive. It is VBS, since .NET doesn't support drive mapping natively.


' --------------------------------------------------------------------------------------
' *** VisualX *** Created by Dalibor Lanik 2006
' --------------------------------------------------------------------------------------

Option Explicit

Dim WshNet

Set WshNet = WScript.CreateObject("WScript.Network")
On Error Resume next

WshNet.MapNetworkDrive "V:", "\\Netcenter01\Files"

Wscript.quit


This maps drive if it's not mapped, but it still fails to open it, and the drive remains offline when I run Zoom.

I eventualy had to run Total Commander and open drive V: (my net drive) in order to make it online.

I came to this XScriptNG solution which is included in my Visual GM skin, but not everyone may notice it there. It maps drive, and then does DIR, which makes it online.

' --------------------------------------------------------------------------------------
' *** VisualX *** Created by Dalibor Lanik 2007
' --------------------------------------------------------------------------------------

Imports System.Diagnostics

Module Script

Public Sub Main()
Dim nri As Integer
Dim StrPath, ContentItem As String
Dim myProcess As Process = new System.Diagnostics.Process()
StrPath = "V:\"

myProcess.StartInfo.FileName = "net"
myProcess.StartInfo.Arguments = "use v: \\Netcenter01\Files"
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
myProcess.Start
myProcess.WaitForExit()
myProcess.Close()

nri = 0

If (System.IO.Directory.Exists(StrPath)) Then
ContentItem = Dir(StrPath + "*.*")

Do Until ContentItem = ""
nri = nri + 1
ContentItem = Dir()
Loop
End If
End Sub

End Module


Hope someone finds it useful.

D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby cmhardwick on Tue Mar 06, 2007 3:25 am

That's fairly typical of windows I've found. I have several mapped drives on my work laptop. When I logon at home of course, it can't reconnect and shows them offline, even after I connect to the company network via VPN. If I open the drive via explorer, it "wakes up" and sees the drive as online. Just attempting to open a file on the share from a shortcut or "recent documents" list fails.

Great little fix dalanik!
cmhardwick
 
Posts: 508
Joined: Fri Jul 14, 2006 6:07 pm
Location: Tennessee

Postby wesblack on Tue Mar 06, 2007 5:39 am

Steven and I have talked about this in great detail. This is an important feature we want added to the Xlobby product line. We hope to add something into the Xlobby Client, Server setup that helps deal with mapped drives, etc. Thanks for the script. Steven and I will look at it.

Wes
wesblack
 
Posts: 852
Joined: Mon Mar 05, 2007 5:02 pm
Location: Valencia, Ca

Postby rhinoman on Tue Mar 06, 2007 9:04 am

I used to have the issue too, its because as the wuindows desktop comes up iot hasn't finished loading the network driver and so the drive doesn't map.

I got round it by using a batch file and wait.exe. The wait.exe was downloaded by microsft and the batch file contained the following

wait 10

net use M: \\server1\media /persistent:no

You can just repeat the line for extra drives.
rhinoman
 
Posts: 416
Joined: Wed Jan 14, 2004 8:58 pm
Location: Herne Bay, UK

Postby S Pittaway on Tue Mar 06, 2007 11:18 am

i use

Code: Select all
REM WAKE THE SERVER
PING -N 1  -L 1  server1
DIR \\server1\media


REM DELETE THE OLD MAPPING
NET DELETE M:


REM RE-MAP THE DIRVE
NET USE      M: \\server1\media /persistent:no



normally, simply doing a PING and a DIR will wake it if the drive is already mapped..
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby dalanik on Tue Mar 06, 2007 1:13 pm

S Pittaway wrote:i use

Code: Select all
REM WAKE THE SERVER
PING -N 1  -L 1  server1
DIR \\server1\media


REM DELETE THE OLD MAPPING
NET DELETE M:


REM RE-MAP THE DIRVE
NET USE      M: \\server1\media /persistent:no



normally, simply doing a PING and a DIR will wake it if the drive is already mapped..


Yes, but I wanted something that wouldn't pop-up the DOS window :-)

D.
dalanik
 
Posts: 885
Joined: Mon Apr 19, 2004 12:35 pm
Location: Prague, Czech Republic

Postby S Pittaway on Tue Mar 06, 2007 1:19 pm

on the os:execute event there is an hide option... :)
S Pittaway
 
Posts: 651
Joined: Wed Jan 25, 2006 11:08 am
Location: Manchester, England

Postby jowaldo on Tue Mar 06, 2007 4:38 pm

S Pittaway wrote:on the os:execute event there is an hide option... :)


That hide option is the best, cuz doin things like that in DOS is easy compared to any scripts.. at least for me ;)
jowaldo
 
Posts: 903
Joined: Wed May 21, 2003 7:17 pm