Recommended Posts

Hi,

We run VB scripts to map network drives at user logon. However, when laptop users go home for the day and logon at home away from the network, these scripts still run and errors pop up from the VB script since the path cannot be found.

Is there a nice way to handle this? Perhaps detect that they are offline and don't bother running the script? Or gracefully dying and telling the user that they're offline so it cannot be mapped? Or ...

Thanks for any advice :)

Link to comment
https://www.neowin.net/forum/topic/451127-mapping-network-drives-while-offline/
Share on other sites

Yes there is ...what I do is I use wmi to get the ssidname of the network. If its true then it will map the drives.

Unfortunaley I don't do vbscript because vbscript is crap. I use monad (MSH) do all my scripts.

I also use net use to map the drives.

Maybe you can adopt it for vb.

[system.Reflection.Assembly]::LoadWithPartialname("Microsoft.VisualBasic") | out-null

$u=new-object Microsoft.VisualBasic.Devices.ServerComputer

#test to see if the network is available

$tr=$u.network.isavailable

if ($tr -eq "True")

{

$a=get-wmiobject -namespace root/wmi "MSNdis_80211_BSSIList where active='true'"

$ssidname=""

#Find the Network Name

for($i=0; $i -lt 7; $i+=1){ $ssidname+=[Char]$a[1].Ndis80211BSSIList[0].Ndis80211SsId[$i]}

If ($ssidname -eq 'Network')

{

$An="Connected to the " + $ssidname + "network"

write-object $an

$a = ping Server

.

.

.

write-object 'Connected to Server'

$m=net use M: '\\Server\My Documents\My Music'

  Quote
Unfortunaley I don't do vbscript because vbscript is crap. I use monad (MSH) do all my scripts.
Oh I see... MSH looks powerful and I see it's still beta so never considered it. I wonder how many other people use it within a production environment...
  Quote
Put the vbs in a GPO in AD. If the client is not connected to AD, then the script can't run. Hence there are no problems.
It is a GPO within AD :] We use Offline Files (for laptop users) and somehow (cause I didn't do it!) this has been picked up as part of it cause I can see it's on the synchronization list. How did it get there? I guess I can just untick it and that should prevent it from being run offline?
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.