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

    • So many things to unpack here I don't even know where to begin...
    • Cjam 1.9.9.0 by Razvan Serea Cjam is a lightweight and fast MP3 editor for Windows that lets you cut, join, and edit MP3 files without re-encoding. This means your audio quality remains untouched, and edits happen instantly. Cjam is ideal for quick, lossless edits—whether you're trimming music, combining tracks, or preparing audio for learning tools or podcasts. It features batch processing, scripting support, cue and playlist file handling, and a simple interface. Cjam is perfect for anyone who needs efficient MP3 editing without the complexity of full audio suites. Cjam requires a PC running Windows 10 or later and Microsoft .NET 6.0 or later. Key features for Cjam: No Re-encoding: Edit MP3 files without losing quality. Cut and Join MP3: Easily cut, trim, and combine MP3 tracks. Batch Processing: Edit multiple files at once for faster workflows. Scriptable Interface: Automate tasks with a custom command language. Cue and Playlist Support: Handle CUE and playlist files for seamless audio management. Fast and Lightweight: Quick processing with minimal system resources. Lossless Audio Editing: Ensure your edits don't affect audio quality. Simple User Interface: Clean, intuitive design for easy navigation. File Format Support: Works with MP3, Cjam-specific file formats (CJAMC, CJAMJ, CJAM). Cjam 1.9.9.0 fixes: Fixed a bug related to playback display on the main screen Download: Cjam 1.9.9.0 | 1.3 MB (Freeware) Links: Cjam Home Page | Cjam Manual | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • "Users may experience repeated KERNEL_SECURITY_CHECK_FAILURE bugchecks after upgrading to this build." This "showstopper" bug/issue is still present for Dev 26200.5651, so NOT QUITE the June 2025 Snapshot for 26200 release but I think we are close to that release so should be within the next couple releases!
    • ah the "quest for more money" continues 🤣
    • Don’t underestimate marijuana because nothing else soothes souls. 
  • Recent Achievements

    • 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
    • Week One Done
      bukro earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      635
    2. 2
      ATLien_0
      281
    3. 3
      +FloatingFatMan
      182
    4. 4
      Michael Scrip
      151
    5. 5
      Steven P.
      117
  • Tell a friend

    Love Neowin? Tell a friend!