Right, ill try to make a short and long version of this so people dont get bored:
Short Version
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.
Long Version
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\
\%USERNAME%'s Profile\
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 to a drive (say Z and then open that Z drive in Explorer.
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.
Alot of questions i know, any help is appreciated.
Karma for help.
/bribe
Cheers
Short Version
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.
Long Version
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\
\%USERNAME%'s Profile\
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 to a drive (say Z and then open that Z drive in Explorer.
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.
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?Code wrote:
' MNDUserNameBonus.vbs
' VBScript to map a network drive to the UserName. And open Explorer
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.2 - September 2005
' -----------------------------------------------------------------'
Option Explicit
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
Call ShowExplorer
WScript.Quit
Sub ShowExplorer()
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" & " " & strDriveLetter & "\" )
End Sub
' End of Example of MapNetworkDrive logon script.
Alot of questions i know, any help is appreciated.
Karma for help.
/bribe
Cheers