map Home folder using vbs
Hi There
I currently use batch files for login scripts and use the following command to map a users home drive
net use h: /home
can someone tell me how to do this in a vbs script
thanks
September 14th, 2010 2:26pm
Hi Tony
Dim Network
Set Network = CreateObject("Wscript.network")
Network.MapNetworkDrive "H", "\Server1\Share"
btw: http://www.lmgtfy.com/?q=drive+map+vbscript ;-D
Cheers,
André
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2010 2:42pm
i need it to map based on the users Home server/folder which is defined in ADUC
This is the what net use h: /home does
September 14th, 2010 2:46pm
Hi Tony
Sorry - I got you wrong... ;-D
This should solve it:
Set WshShell = WScript.CreateObject("WScript.Shell")
vHomeFolder = WshShell.ExpandEnvironmentStrings("%HomeShare%")
Set Network = CreateObject("Wscript.network")
Network.MapNetworkDrive "H", vHomeFolder
Does it work like that?
Cheers,
André
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2010 3:04pm
I'm getting the following error when i run the vbs script
Line: 4
Char: 1
Error: The specified device name is invalid
Code: 800704B0
Source: WSHNetwork.MapNetworkDrive
September 14th, 2010 3:31pm
I have a sample script on my site:
Mapping Network Drives Using VBScript
http://www.anitkb.com/2010/03/mapping-network-drives-via-vbscript.html
If you have defined a "Home Folder" in the User Account's Profile tab, the mapping should occur when the user logs on the domain (without the use of scripts).
Visit: anITKB.com, an IT Knowledge Base.
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2010 4:19pm
Try the following to check, whether there is the right path in the variable:
Set WshShell = WScript.CreateObject("WScript.Shell")
vHomeFolder = WshShell.ExpandEnvironmentStrings("%HomeShare%")
Set Network = CreateObject("Wscript.network")
MsgBox(vHomeFolder)
Network.MapNetworkDrive "H", vHomeFolder
Cheers,
André
September 14th, 2010 4:41pm
btw: If you fire up a CMD.exe and type there "set", than you will see all the system variables. One of them is the "HOMESHARE"-variable, which I include in the script. There should be the UNC path, which you entered in ADUC. If you see another variable,
in which this resists, than just change the name of the variable in the code.
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2010 4:46pm
Hello Tony,
As this issue is related to Scripting, I suggest discussing it in our Scripting forum. They are the best resource to troubleshoot this issue.
The Official Scripting Guys Forum!
http://social.technet.microsoft.com/Forums/en/ITCG/threads
Brent Hu,Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
September 16th, 2010 10:06am