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

    • Comments like these are genuinely fascinating to me because they're so far from anything I experience as a daily user of Win 11 since the first public beta. AI stuff? Have it turned off completely, never pops up anywhere. Forced MS account? Yes, they strongly recommend it and kinda push it lately during big updates and such, but it's still not forced. Pop up dialogs when you're not using Edge? Yeah, I vaguely remember seeing some reminders about using Edge a long time ago. I just clicked them away and kept using Vivaldi as usual (but frankly, I'd still much rather use Edge than Chrome - which I'm forced to use at work - I've grown to dislike Google a lot more than Microsoft lately, even if I am still deeply rooted in their ecosystem unfortunately). Awful context menus? A single simple tweak will get you the old context menus. Search in Windows using Bing? People use search in Windows for anything else than to search for local files or apps? Why? I just don't get a lot of the complains people have about Win 11.
    • Nice, but if you change the colour, the folder no longer shows image preview on the actual folder icon.
    • Taiwan hits Huawei and SMIC with new export restrictions by David Uzondu Taiwan has added Huawei and Semiconductor Manufacturing International Corporation, or SMIC, to its export control entity list. According to CNBC, this means companies in Taiwan now need a special license to ship certain high-tech goods to these two mainland Chinese firms. The conflict has been escalating for a while. The United States government, for instance, has been going after Huawei since at least 2019, putting the telecom equipment maker on its own Entity List over national security fears. The worry has always been about Huawei's connections to the Chinese government and the potential for its network gear to be used for spying. The United Kingdom eventually followed suit, ordering all Huawei 5G equipment to be ripped out of its networks by 2027. Remember, in December 2020, the US added SMIC to its Entity List over its alleged ties to the Chinese military. The goal was to choke off the chipmaker's access to the tools it needs to produce the most advanced semiconductors. Despite all the pressure, the two firms managed to collaborate and produce a 7nm chip for Huawei's Mate 60 phone, which annoyed some people in Washington who thought the sanctions had completely crippled China's chipmaking ambitions. This new blacklisting from Taiwan just tightens the screws even more. Last year, research firm TechInsights found a TSMC-made chip inside a Huawei AI training card. That was a huge "oh no" moment because it showed that, despite all the American restrictions, Huawei was still getting its hands on advanced Taiwanese silicon. That discovery led directly to the U.S. Commerce Department leaning on TSMC to shut down access for Chinese clients to specific AI chips. Huawei had cleverly exploited loopholes to hoard millions of GPU dies for its Ascend AI chip program, a direct attempt to build a homegrown alternative to Nvidia's dominant hardware. For Taiwan, this feels less like a trade issue and more like a matter of survival. The island's lead in chipmaking, largely thanks to TSMC, is often seen as its "silicon shield." The idea is that global reliance on Taiwanese chips makes any military action by China a huge risk for the world. Letting its most advanced tech reach the country that threatens its very existence could seriously weaken that shield. Source: CNBC
    • Anything is "news worthy" if it's new and someone writes about it. Something like an inconsequential note about "correcting a typo in the readme file" buried deep in the changelog could become "news worthy". And, on related note, anything can be used as a justification to complain about something one is clearly already biased against. Say, if someone's biased against Windows 11, they could see even an inconsequential change like an added time display as a reason to rant about "Microsoft these days"... ¯\_(ツ)_/¯
    • I expect i will always have the choice, I doubt I will be around to see self drive cars on the roads in any great amounts. I can understand where your wife is coming from, but then being in a car alone can have other problems.
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      615
    2. 2
      ATLien_0
      277
    3. 3
      +FloatingFatMan
      180
    4. 4
      Michael Scrip
      150
    5. 5
      Steven P.
      115
  • Tell a friend

    Love Neowin? Tell a friend!