[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1229
  • Last Modified:

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
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHC8550"
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHL4200"
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHP1050"
 
'Set Default Printer
objPrinter.SetDefaultPrinter "\\printserver\CITHL4200"
Wscript.Quit
 
'End of Windows Logon Script

Open in new window

0
GarfieldCO
Asked:
GarfieldCO
  • 9
  • 4
1 Solution
 
TDKDCommented:
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
 
TDKDCommented:
I also meant FQDN where I used FQDM...lol
0
 
GarfieldCOAuthor Commented:
I tried your suggestion and it still only showed my z and t drive. This is bizarre.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GarfieldCOAuthor 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
 
TDKDCommented:
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
 
TDKDCommented:
One more thing....the drives that are not showing have "Enable Offline Use" enabled?
0
 
GarfieldCOAuthor 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
 
TDKDCommented:
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
 
TDKDCommented:
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
 
TDKDCommented:
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
 
TDKDCommented:
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
 
GarfieldCOAuthor 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
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHC8550"
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHL4200"
objPrinter.AddWindowsPrinterConnection "\\printserver\CITHP1050"
 
Wscript.Quit
 
'End of Windows Logon Script

Open in new window

0
 
TDKDCommented:
Excellent, Great job!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 9
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now