Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapped drive

Status
Not open for further replies.

hooverd

Technical User
May 18, 2006
16
US
I have been searching this and other forums to find how to map a users home drive. Our enviroment is locked down and the user shares are hidden ($). Nothing I have tried has worked. The mapping works great in a .bat format.
Thanks hooverd
 
My FAQ covers all you need. faq329-5798

When mapping to a hidden share you simply have to specify the $ at the end of the share name just as you would any other share.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Thank you Mark but I have tried that from your post several times and in different ways and can't get it to
work. Here is some of my script.. I is the designated drive letter.


oNetwork.MapNetworkDrive "h:", "\\CSCFS\prod"
On Error Resume Next
oNetwork.MapNetworkDrive "i:", "\\CSCAPP1\users\username$"
On Error Resume Next
oNetwork.MapNetworkDrive "x:", "\\CSCAPP1\apps"
On Error Resume Next
oNetwork.MapNetworkDrive "K", "\\CSCAPP1\ServicemailPool"
On Error Resume Next
oNetwork.MapNetworkDrive "O", "\\Dap\image$"
On Error Resume Next
oNetwork.MapNetworkDrive "S", "\\CSCAPP1\Information Resource Center for EDS"

oNetwork.MapNetworkDrive "I:", "\\CSCAPP1\users\" & UserString, "$",True

Thanks
 
And this ?
oNetwork.MapNetworkDrive "I:", "\\CSCAPP1\users\" & UserString & "$"

Hopefully I: is not yet mapped at this time.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Exactly as PHV said.

As you coded it you were looking for a hidden share with the name of "username" rather than substituting the username in the string.

Direct quote from my FAQ:
WSHNetwork.MapNetworkDrive "H:", "\\server\users\" & UserString,True[/quopte]

As you can see the UserString is called out after the &. Adding the hidden attirbut only requires addign the

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
No the I drive is not mapped at this time.
Thanks
 
I know this sounds stupid but I have tried every combination of your methods and it still dowsn't work.
Thanks
 
The mapping works great in a .bat format
Any chance you could share that code and the corresponding "non working" VBS oode ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The lines I pasted are from my VBS script all the drive mappings shown work great except for the line for the users home directory.
Yes in the batch format it works fine for all. Just not in vbs format.
Thanks
 
So, WHAT is working in the BAT file (ie HOW DO YOU MAP THE I: DRIVE)?
What is UserString in your VBS code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This is from my .bat file
net use i: \\cscapp1\%username%$

net use k: /d
net use k: \\cscapp1\servicemailpool

net use g: /d
net use g: \\cscfs\smart\prod

net use h: /d
NET USE H: \\cscfs\smart\COMMON

net use o: /d
net use o: \\DAP\image$ /persistent:no

net use s: /d
net use s: \\cscapp1\Information Resource Center for EDS

net use x: /d
net use x: \\cscapp1\apps

This all works, as it all works in the script except the one line for the users home drive.
The line in my script obviously is wrong, but I need it to work. Any ideas will be a great help
Thanks
 
net use i: \\cscapp1\%username%$
Provided UserString contains the username:
oNetwork.MapNetworkDrive "I:", "\\CSCAPP1\" & UserString & "$"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Since we can't rely on getting details here...
Code:
UserString = Network.UserName
oNetwork.MapNetworkDrive "I:", "\\CSCAPP1\" & UserString & "$"

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Ok here is the whole script. everything works EXCEPT the line to map the users Home drive (i:)


Option Explicit

' Declare basic objects
dim wshFSO : Set wshFSO = CreateObject("Scripting.FileSystemObject")
dim wshShell : Set wshShell = CreateObject("WScript.Shell")
dim wshSysEnv': Set wshSysEnv = wshShell.Environment ("system")
Dim wshUsrEnv : Set wshUsrEnv = wshShell.Environment("User")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
Dim wshNet : Set wshNet = WScript.CreateObject("WScript.Network")
Dim wshArgs : Set wshArgs = WScript.Arguments


Const WindowsFolder = 0
Const SystemFolder = 1
Const TemporaryFolder = 2
Const Deleteall1 = True
Const Deleteall2 = True
On Error Resume Next
Set wshFSO = CreateObject("Scripting.FileSystemObject")
wshFSO.DeleteFile("C:\Temp\*.*")
On Error Resume Next
Set wshFSO = CreateObject("Scripting.FileSystemObject")
wshFSO.DeleteFolder("C:\Temp\*.*")
On Error Resume Next

dim I
dim blnVerbose : blnVerbose = False
dim blnQuiet : blnQuiet = False
dim blnAskRegistry : blnAskRegistry = False
For I = 0 to wshArgs.Count - 1
blnVerbose = blnVerbose Or (wshArgs(I)="/v") Or (wshArgs(I)="/V")
blnQuiet = blnQuiet Or (wshArgs(I)="/q") Or (wshArgs(I)="/Q")
blnAskRegistry = blnAskRegistry Or (wshArgs(I)="/r") Or (wshArgs(I)="/R")
Next
dim blnShowErrors : blnShowErrors = Not blnQuiet



' Get the system temporary folder
dim strSysTempFolder
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)


dim arrFolderList

arrFolderList = array( _
wshShell.SpecialFolders(""), _
strSysTempFolder, _
wshFSO.GetSpecialFolder(TemporaryFolder).Path, _
WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Cache") _
)


dim strFolderI
For Each strFolderI in arrFolderList
If blnVerbose Then
Echo("- " & strFolderI)
End If
FolderDelete strFolderI, True, blnShowErrors
Next



dim arrRegistryList

arrRegistryList = array( _
"[-HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\RecentFileList]")


Dim strTempName : strTempName = wshFSO.GetTempName
dim oTempFile : Set oTempFile = CreateTempFile(strTempName)

oTempFile.WriteLine "REGEDIT4"

dim strRegistryI
For Each strRegistryI in arrRegistryList
If blnVerbose Then
Echo("- " & strRegistryI)
End If
oTempFile.WriteLine strRegistryI
Next
oTempFile.Close


dim strCommand : strCommand = "Regedit "

If Not blnAskRegistry Then strCommand = strCommand & "/s "
strCommand = strCommand & strTempName
wshShell.Run strCommand, 1, True
wshFSO.DeleteFile strTempName



Sub FolderDelete(strBaseFolder, blnContentOnly, blnShowErrors)

If wshFSO.FolderExists(strBaseFolder) Then

dim oBaseFolder : Set oBaseFolder = wshFSO.GetFolder(strBaseFolder)
dim oFolderI, oFileI
For Each oFolderI in oBaseFolder.SubFolders
FolderDelete oFolderI.Path, False, blnShowErrors
Next

For Each oFileI in oBaseFolder.Files
On Error Resume Next
oFileI.Delete
If Err.number <> 0 Then
If blnShowErrors Then

End If
Err.Clear
End If
On Error Goto 0
Next
If not blnContentOnly Then
On Error Resume Next
oBaseFolder.Delete
If Err.number <> 0 Then
If blnShowErrors Then

End If
Err.Clear
End If
On Error Goto 0
End If
End If

End Sub




Function CreateTempFile(ByRef strTempName)

Dim oTempFolder, oTempFile
Set oTempFolder = wshFSO.GetSpecialFolder(TemporaryFolder)
Set oTempFile = oTempFolder.CreateTextFile(strTempName)
strTempName = oTempFolder.Path & "\" & strTempName
Set CreateTempFile = oTempFile

End Function

Sub Echo(ByVal strMessage)

If Not blnQuiet then
Wscript.Echo(strMessage)
End If

End Sub

Dim oNetwork
set oNetwork = CreateObject("WScript.Network")
On Error Resume Next
oNetwork.MapNetworkDrive "g:", "\\CSCFS\common"
On Error Resume Next
oNetwork.MapNetworkDrive "h:", "\\CSCFS\prod"
On Error Resume Next
wshNet.MapNetworkDrive "i:", "\\CSCAPP1\%username%$"
On Error Resume Next
oNetwork.MapNetworkDrive "x:", "\\CSCAPP1\apps"
On Error Resume Next
oNetwork.MapNetworkDrive "k", "\\CSCAPP1\ServicemailPool"
On Error Resume Next
oNetwork.MapNetworkDrive "O", "\\Dap\image$"
On Error Resume Next
oNetwork.MapNetworkDrive "s", "\\CSCAPP1\Information Resource Center for EDS"





'The End
'-------
 
Replace this:
wshNet.MapNetworkDrive "i:", "\\CSCAPP1\%username%$"
with this:
wshNet.MapNetworkDrive "i:", "\\CSCAPP1\" & wshNet.UserName & "$"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That worked... Thank you very much. I knew it was something simple.
Thanks again
hooverd
 
I wonder how many times a message need repeated before being heard?!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top