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

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

###### Who is Participating?

Author Commented:
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

Commented:
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

Commented:
I also meant FQDN where I used FQDM...lol
0

Author Commented:
I tried your suggestion and it still only showed my z and t drive. This is bizarre.
0

Author Commented:
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

Commented:
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

Commented:
One more thing....the drives that are not showing have "Enable Offline Use" enabled?
0

Author Commented:
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

Commented:
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

Commented:
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

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

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

Commented:
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

Commented:
Excellent, Great job!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.