Long time reader... but infrequent poster - be kind!
I want to create a log on script that maps \\Server\Users\%USERNAME%\%USERNAME%'s Documents\ to Z: and then have Windows Explorer pop up showing the new folder.
***I want to clear up now - when i set up the Roaming Profiles, i used the %USERNAME% variable (to move the profile folder to C:\Users Shared Folder\%USERNAME%\%USERNAME%'s Profile\) - but now with Windows XP and special folders, once in the user account, the %USERNAME%'s Documents folder doesnt show as Fred's Documents (for example), but "My Documents". So, i dont know in these scripts if i need to specify \%USERNAME%'s Documents or \My Documents***
I have a sever and a couple of workstations setup with Roaming User Profiles and "My Documents" all stored on the server. The file structure on the server is:
C:\Users Shared Folder\%USERNAME%\%USERNAME%'s Documents\
So im trying to say the Profile and Documents are in the same folder (%USERNAME%) on the server, so all the information for each user (their documents and profile data) are stored in a folder on the server, called their username.
The server is Windows 2K3 SBS, workstations are XP Pro.
Ive been using this site for guidance.
What i want is to run a script at logon that will connect the "%USERNAME%'s Documents" folder (on the server) to a drive (say Z:) (on the user's workstation) and then open that Z drive in Explorer on the user's pc.
But using the link above i can only get to "\%USERNAME%\" (the folder above what i want). I want it to map straight to the "%USERNAME%'s Documents" folder, so the Profile folder isnt shown, as now the profile folder is shown by mapping to \%USERNAME%, (so they cant muck about with it).
What's the code? Im using the template below, but I have no idea of VBScript.
' VBScript to map a network drive to the UserName. And open Explorer
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.2 - September 2005
Dim objNetwork, objShell
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "X:"
strRemotePath = "\\grand\home\"
' Purpose of the script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method. Result K: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
' Here is where we extract the UserName
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & strUserName
' Bonus code to open Explorer at the mapped drive letter
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" & " " & strDriveLetter & "\" )
' End of Example of MapNetworkDrive logon script.
I can use NET USE, and that works to map the drive with the %USERNAME% variable, but it dont know how to get it to open the folder afterwards. Also i dont know the differences of using NET USE (ie .cmd) compared to objNetwork.MapNetworkDrive (ie .vbs). Is there a way to combine the both commands? Or is there a way to complete both objectives using one of them? Whats the differnce between cmd and vbs files for logon scripts? Which are better?
Alot of questions i know, any help is appreciated.
Edited by Major_Disaster, 27 December 2007 - 22:00.