Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: mapping drive letter to wireless storage

Reply
 
Old 07-04-2009   #1 (permalink)
Pegasus [MVP]


 
 

Re: mapping drive letter to wireless storage


"Joe King" <br25354@xxxxxx> wrote in message
news:Xns9C3E9046B1A11joekingaolcouk@xxxxxx
Quote:

> my script runs while the IP address is still being obtained.
> is there a way to hold or pause the script until IP has been assigned?
>
> thanks
Yes - determine the IP address (e.g. with ipconfig.exe) and loop until you
get a valid value.



My System SpecsSystem Spec
Old 07-04-2009   #2 (permalink)
Mark D. MacLachlan


 
 

Re: mapping drive letter to wireless storage

Joe King wrote:
Quote:

> my script runs while the IP address is still being obtained.
> is there a way to hold or pause the script until IP has been assigned?
>
> thanks
Is it a login script or a startup script? Need you to provide more
details on what you are doing. Is the script applied via GPO? If so
then configure to wait for network.

Mark

--

My System SpecsSystem Spec
Old 07-05-2009   #3 (permalink)
Joe King


 
 

Re: mapping drive letter to wireless storage

"Mark D. MacLachlan" <markdmac@xxxxxx> wrote in news:#PCxjAP$JHA.3708
@TK2MSFTNGP02.phx.gbl:
Quote:

> Joe King wrote:
>
Quote:

>> my script runs while the IP address is still being obtained.
>> is there a way to hold or pause the script until IP has been assigned?
>>
>> thanks
>
> Is it a login script or a startup script? Need you to provide more
> details on what you are doing. Is the script applied via GPO? If so
> then configure to wait for network.
>
> Mark
>
- this is for a home network
- router acting as server
- external HDD attached to router
- users in system want to use HDD as shared data
- desktop maps drive properly, as there is no wait for WLAN discovery and
IP assignment

laptops, however, fail to map drive letter on startup script because device
hasn't been discoverd yet (takes about 20 seconds)
My System SpecsSystem Spec
Old 07-05-2009   #4 (permalink)
Mark D. MacLachlan


 
 

Re: mapping drive letter to wireless storage

Joe King wrote:
Quote:

> "Mark D. MacLachlan" <markdmac@xxxxxx> wrote in
> news:#PCxjAP$JHA.3708 @TK2MSFTNGP02.phx.gbl:
>
Quote:

> > Joe King wrote:
> >
Quote:

> >> my script runs while the IP address is still being obtained.
> >> is there a way to hold or pause the script until IP has been
> assigned? >>
Quote:
Quote:

> >> thanks
> >
> > Is it a login script or a startup script? Need you to provide more
> > details on what you are doing. Is the script applied via GPO? If
> > so then configure to wait for network.
> >
> > Mark
> >
>
> - this is for a home network
> - router acting as server
> - external HDD attached to router
> - users in system want to use HDD as shared data
> - desktop maps drive properly, as there is no wait for WLAN discovery
> and IP assignment
>
> laptops, however, fail to map drive letter on startup script because
> device hasn't been discoverd yet (takes about 20 seconds)
OK, so how about just adding a sleep command to the script before you
map the drive?

Give it a 30 second delay just to be sure:

WScript.Sleep 30000

You might also want to check out the Iomega line, they have an external
drive that has an RJ45 and works very much like a NAS. I just
purchased a 1TB drive yesterday for $175. Larger sizes are available.

I also tried the NetGear SC101T. I would not recommend that. Doesn't
work with x64 systems and Vista support is terrible. Plus it was
taking over 12 hours to format a 500GB drive and mirror it. I had to
take that back and get the Iomega.

Hope that is helpful,

Mark D. MacLachlan

--

My System SpecsSystem Spec
Old 07-05-2009   #5 (permalink)
James Whitlow


 
 

Re: mapping drive letter to wireless storage

"Joe King" <br25354@xxxxxx> wrote in message
news:Xns9C3F56E919F52joekingaolcouk@xxxxxx
Quote:

> "Mark D. MacLachlan" <markdmac@xxxxxx> wrote in news:#PCxjAP$JHA.3708
> @TK2MSFTNGP02.phx.gbl:
>
Quote:

>> Joe King wrote:
>>
Quote:

>>> my script runs while the IP address is still being obtained.
>>> is there a way to hold or pause the script until IP has been assigned?
>>>
>>> thanks
>>
>> Is it a login script or a startup script? Need you to provide more
>> details on what you are doing. Is the script applied via GPO? If so
>> then configure to wait for network.
>>
>> Mark
>>
>
> - this is for a home network
> - router acting as server
> - external HDD attached to router
> - users in system want to use HDD as shared data
> - desktop maps drive properly, as there is no wait for WLAN discovery and
> IP assignment
>
> laptops, however, fail to map drive letter on startup script because
> device
> hasn't been discoverd yet (takes about 20 seconds)
A slightly kludgy method would be to ping the default gateway until you
get a reply:

sGateway = "192.168.1.254"
Do
Set oPing = GetObject("winmgmts:").InstancesOf("Win32_PingStatus" _
& " WHERE Address='" & sGateway & "' AND statusCode=0")
WScript.Sleep 1000
Loop Until oPing.Count = 1


My System SpecsSystem Spec
Old 08-04-2009   #6 (permalink)
shadowbq


 
 

Re: mapping drive letter to wireless storage

Option Explicit

'launch with "cscript c:\nasmapper.vbs //nologo" -> /programs/startup
'VBS Script to map NAS over wifi homenets (non GPO script)

'Shadowbq - 2009 BSD License
'Reference Functions: ScriptGuy! (MS), quiet_lurker (neowin), Aaron P
(neowin)


Dim objWMIService, objNet
Dim intSleep, WNICName, knownSSID, retries, maxRetries
Dim mapDrive, mapLocation, mapUsername, mapPassword

knownSSID="URWP80" 'SSID of Hotspot that has mapped location
WNICName="Dell Wireless 1470 Dual Band WLAN Mini-PCI Card" 'Nic name
listed in WMI
maxRetries = 10 'maxRetries * intSleep/1000 ~= total possible
seconds
intSleep = 2000 'wait cycles
mapDrive = "Y:" 'Map to Drive
mapLocation = "\\storage\public" 'Location of Share
mapUsername = "Guest" 'User Account for Share
mapPassword = "" 'User Password for Share

'If your having problems finding the WNICName you can use the
'\\root\wmi call to ("Select * From MSNdis_80211_Configuration") flip
through all wireless devices..


Private Sub GetWMI(WMIArray, WMIQuery, WMIRoot)
'On error resume Next
DIM WMIClass

Set WMIClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\
\.\root\" & WMIRoot)
If not(WMIClass is nothing) Then Set WMIArray = WMIClass.ExecQuery
(WMIQuery)

End Sub


Function SSID()
'On error resume Next
DIM objSSIDSet, objSSID, ID, i

Call GetWMI(objSSIDSet, "Select * from
MSNdis_80211_ServiceSetIdentifier Where active=true", "wmi")

For Each objSSID in objSSIDSet
ID = ""

For i = 0 to objSSID.Ndis80211SsId(0)
ID = ID & chr(objSSID.Ndis80211SsId(i + 4))
Next

SSID = ID
Next
End Function

Function WNICStatus()
Dim colItems, objItem, strStatus

Call GetWMI(colItems, "Select * from Win32_NetworkAdapter where Name
= '" & WNICName & "'", "cimv2")

For Each objItem in colItems
Select Case objItem.NetConnectionStatus
Case 0 strStatus = "Disconnected"
Case 1 strStatus = "Connecting"
Case 2 strStatus = "Connected"
Case 3 strStatus = "Disconnecting"
Case 4 strStatus = "Hardware not present"
Case 5 strStatus = "Hardware disabled"
Case 6 strStatus = "Hardware malfunction"
Case 7 strStatus = "Media disconnected"
Case 8 strStatus = "Authenticating"
Case 9 strStatus = "Authentication succeeded"
Case 10 strStatus = "Authentication failed"
Case 11 strStatus = "Invalid address"
Case 12 strStatus = "Credentials required"
End Select
Next

WNICStatus = strStatus
End Function

Function fnMapNetworkDrive (Drive, Path, Uname, Upass)
Dim i, oDrives
set objNet = Wscript.CreateObject("Wscript.Network")
Set oDrives = objNet.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2 ' Find out if an existing
network drive exists
If oDrives.Item(i) = Drive Then
WScript.Echo "Removing drive: " & Drive
objNet.RemoveNetworkDrive Drive, true, true
End If
Next
WScript.Echo "Mapping drive: " & Drive & " to path: " & Path
objNet.MapNetworkDrive Drive, Path, false, Uname, Upass
fnMapNetworkDrive = "[completed mapping drive]"
Set i = Nothing
Set oDrives = Nothing
Set Drive = Nothing
Set Path = Nothing
End Function

Dim nicStatus, nicSSID

WScript.Echo "NAS Wifi Mapper"
WScript.Echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
WScript.Echo "[Checking NIC Status]"

nicStatus = WNICStatus()
retries = 0

while (StrComp(nicStatus, "Connected") <> 0)
If (retries < maxRetries) Then
retries = retries + 1
Wscript.Echo "Nic " & nicStatus & ".."
Wscript.Sleep intSleep
nicStatus = WNICStatus()
Else
Wscript.Error "*** Max # of connection attempts reached"
End If
Wend
Wscript.Echo "Connected .. continuing"

WScript.Echo "[Checking SSID Status]"
nicSSID = SSID()
nicSSID = Left(nicSSID, len(nicSSID)-1)

Wscript.Echo "SSID: " & nicSSID

If (StrComp(nicSSID, knownSSID) = 0) Then
Wscript.Echo "[Correct SSID]"
Else
On Error Resume Next
Dim errDescription, errSource
errSource = "NAS Mapper"
errDescription = "Incorrect SSID for network share to be
established"
Wscript.Echo "An Error:'" & errDescription & "' by '" & errSource &
"'."
WScript.Quit 8
End If

WScript.Echo "[Mapping Drive] "
Wscript.Echo fnMapNetworkDrive (mapDrive, mapLocation, mapUsername,
mapPassword)

WScript.Quit

My System SpecsSystem Spec
Old 08-05-2009   #7 (permalink)
Eric


 
 

Re: mapping drive letter to wireless storage


"Mark D. MacLachlan" <markdmac@xxxxxx> wrote in message
news:eqgRXAY$JHA.3732@xxxxxx
Quote:

> OK, so how about just adding a sleep command to the script before you
> map the drive?
>
> Give it a 30 second delay just to be sure:
>
> WScript.Sleep 30000
>
> You might also want to check out the Iomega line, they have an external
> drive that has an RJ45 and works very much like a NAS. I just
> purchased a 1TB drive yesterday for $175. Larger sizes are available.
>
> I also tried the NetGear SC101T. I would not recommend that. Doesn't
> work with x64 systems and Vista support is terrible. Plus it was
> taking over 12 hours to format a 500GB drive and mirror it. I had to
> take that back and get the Iomega.
>
> Hope that is helpful,
>
> Mark D. MacLachlan
>
> --
Why would you pay $175 for a 1TB drive? what model?
If you check tigerdirect, they have external 1TB for as low as $89.99.
http://www.tigerdirect.com/applicati...=Price&dir=asc
The one I thought looks really nice is only $109.99 after $40 of rebates at
PCMall.
http://www.pcmall.com/pcmall/shop/de...0Hard%20Drives


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Flash Drive has no drive letter... Not in Disk Management Vista hardware & devices
Phantom CD Drive after reassigning Recovery Partition drive letter Vista installation & setup
LastWriteTime and Locating the drive letter of a flash drive. PowerShell
USB drive letters and mapped drive letter issues Vista hardware & devices
USB drive letters and mapped drive letter issues Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46