Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mapping drive letter to wireless storage

46 views
Skip to first unread message

Joe King

unread,
Jul 4, 2009, 2:10:59 PM7/4/09
to
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

Pegasus [MVP]

unread,
Jul 4, 2009, 3:05:16 PM7/4/09
to

"Joe King" <br2...@aol.co.uk> wrote in message
news:Xns9C3E9046B1A1...@74.209.136.83...

> 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.


Mark D. MacLachlan

unread,
Jul 4, 2009, 5:41:06 PM7/4/09
to
Joe King wrote:

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

--

Joe King

unread,
Jul 5, 2009, 8:32:39 AM7/5/09
to
"Mark D. MacLachlan" <mark...@live.com> wrote in news:#PCxjAP$JHA.3708
@TK2MSFTNGP02.phx.gbl:

- 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)

Mark D. MacLachlan

unread,
Jul 5, 2009, 10:51:32 AM7/5/09
to
Joe King wrote:

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

--

James Whitlow

unread,
Jul 5, 2009, 5:10:51 PM7/5/09
to

"Joe King" <br2...@aol.co.uk> wrote in message
news:Xns9C3F56E919F5...@74.209.136.85...

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


shadowbq

unread,
Aug 4, 2009, 10:23:14 PM8/4/09
to
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

Eric

unread,
Aug 5, 2009, 8:40:51 AM8/5/09
to

"Mark D. MacLachlan" <mark...@live.com> wrote in message
news:eqgRXAY$JHA....@TK2MSFTNGP02.phx.gbl...

> 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/applications/SearchTools/search.asp?keywords=1TB%20external&sort=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/detail.asp?dpno=7816075&Redir=1&description=Fantom%20Drives-GreenDrive%201TB%20Quad%20Interface%20External%20eSATA/FireWire%20800&400/USB%202.0%20Hard%20Drive-External%20Hard%20Drives


0 new messages