Solved

# Offline folders drive missing when not connected to network. Mapped via vbscript

Posted on 2008-11-18
1,196 Views
We have recently converted our login scripts from .bat files to vbscript files. We are enabling them through a group policy. On my laptop I have the My Documents drive pointing to my user drive that is mapped from the login script.

The issue is that when i am not connected to the network and start up the computer my user drive is missing and I get an error when trying to open My Documents. Offlline files are enabled. Also I have no problems if I log into the vpn manually run the script then disconnect the vpn.

Another weird thing is that the other drives that are mapped via the login script are present and just show a disconnected icon.

I am attaching the scipt in case that might help.
' IT Department

' -----------------------------------------------------------------'

Option Explicit

'Objects

Dim objNetwork

Dim objPrinter

Set objNetwork = CreateObject("WScript.Network")

Set objPrinter = CreateObject("WScript.Network")

'Delete Existing Mapped Drives

On Error Resume Next

objNetwork.RemoveNetworkDrive "u:"

objNetwork.RemoveNetworkDrive "t:"

objNetwork.RemoveNetworkDrive "Z:"

'Drive Mapping Section

objNetwork.MapNetworkDrive "u:", "\\server\homedir$\it\" & objNetwork.UserName objNetwork.MapNetworkDrive "t:", "\\server\INFORMATIONSYSTEMS" objNetwork.MapNetworkDrive "Z:", "\\server\GCSW$"

'Printer Mapping Section

'Set Default Printer

objPrinter.SetDefaultPrinter "\\printserver\CITHL4200"

Wscript.Quit

'End of Windows Logon Script

0
Question by:GarfieldCO

LVL 8

Expert Comment

Hi,

The reason for the error is most likely because you are using the servers FQDM (Offline files does not like FQDN), use the IP address instead, all should work after this change.

e.g. objNetwork.MapNetworkDrive "u:", "\\124.122.201.54\homedir$\it\" & objNetwork.UserName Regards, Tony D. MCSE/MCSA/A+ 0 LVL 8 Expert Comment I also meant FQDN where I used FQDM...lol 0 Author Comment I tried your suggestion and it still only showed my z and t drive. This is bizarre. 0 Author Comment Is there an equivilant of a persistent command I could use in this situation? I assume that it is implied since the other drives appear after a reboot. 0 LVL 8 Expert Comment You will have to disable the offline files option on the client PC, then delete offline files (both shadow copies), then enable offline files again and run the script agin with the IP address's. This works for my users, so the only thing I can think of is that you already had run the script with FQDN and not IP's? Also, an easy way to see if Im correct, is to run the script on a PC it has not been run on. Warm Regards, Tony D. 0 LVL 8 Expert Comment One more thing....the drives that are not showing have "Enable Offline Use" enabled? 0 Author Comment Yeah the drives are set up correctly for offline use. I deleted all the offline files. turned off offline files, restarted then ran the new script. Enabled offline files Remapped My documents, synchronized then shut down my computer disconnected from network and restarted. Still the same. No "U" drive and an error when trying to access My Documents 0 LVL 8 Expert Comment It works fine for my users, I have a batch file copy the users content (some of it I exclude the My Pics and Music folders) to a folder on their U drive then I make the "My Documents" (this is the folder I redirect) available offline and encrypted. Maybe I should send you what I did and it may give you some ideas?? 0 LVL 8 Expert Comment Hi GarfieldCO, I was looking at how I did the offline files with encryption on a domain; I actually made the "My Documents" folder offline and encrypted all "Offline data" via the GPO, in conjunction with my scripts and bat files. 0 LVL 8 Expert Comment I also create a system restore point, then redirect the "My Documents" by way of the registry through a vbs script.. Set IRP = getobject("winmgmts:\\.\root\default:Systemrestore") MYRP = IRP.createrestorepoint ("My Restore Point", 0, 100) sMyDocPath = "\\IPADDRESS\isusers\%username%\My Documents IS" Set oShell = CreateObject("WScript.Shell") oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\" _ & "Explorer\Shell Folders\Personal", sMyDocPath, "REG_SZ" oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\" _ & "Explorer\User Shell Folders\Personal", sMyDocPath, "REG_EXPAND_SZ" 0 LVL 8 Expert Comment Also the script (only a portion of it above) will not run if it has already run once on a computer due to certain criteria I set in the batch file wich then executes the vbs script. I hope some of this is at least giving you ideas?? Sincerely, Tony D. 0 Accepted Solution Well after playing around with it a bit. I think I may have solved the issue. I added some extra code to the script to make it work. strProfile = "true" Then I added the "strProfile" to the end of each mapping statement. That seemed to do the trick. After some more research I found that this statement binds the mapping to the user not the session. I will attach the new code to show what I did. ' IT Department ' -----------------------------------------------------------------' Option Explicit 'Objects Dim objNetwork Dim objPrinter Dim strProfile Set objNetwork = CreateObject("WScript.Network") Set objPrinter = CreateObject("WScript.Network") strProfile = "true" 'Delete Existing Mapped Drives On Error Resume Next objNetwork.RemoveNetworkDrive "u:" objNetwork.RemoveNetworkDrive "t:" objNetwork.RemoveNetworkDrive "Z:" 'Drive Mapping Section objNetwork.MapNetworkDrive "u:", "\\server\homedir$\" & objNetwork.UserName, strProfile

objNetwork.MapNetworkDrive "t:", "\\server\INFORMATIONSYSTEMS", strProfile

objNetwork.MapNetworkDrive "Z:",  "\\server\GCSW\$", strProfile

'Printer Mapping Section

Wscript.Quit

'End of Windows Logon Script

0

LVL 8

Expert Comment

Excellent, Great job!!
0

## Featured Post

### Suggested Solutions

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…