Re: map web folder
- From: Derek Feagin <ddfeagi@xxxxxxxx>
- Date: Wed, 06 Apr 2005 17:54:13 -0700
I ran through the creation script one time today and it worked like a charm! I had posted the same question to someone else and they sent this code to me as well today... I have not had time to try it as of yet...
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\Folder_Name.lnk")
oShellLink.TargetPath = \\Server_Name\Folder_Name$
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "CTRL+SHIFT+H"
oShellLink.IconLocation = \\Server_Name\Folder_Name$
oShellLink.Description = "Shortcut To Folder"
oShellLink.WorkingDirectory = strDesktop
oShellLink.SaveThanks Derek
Hello mia_cid@xxxxxxxxxxx,
Hi all,
Thanks for the advice, I'm just about to have a read through the links you guys posted, until then here is the script to create a web folder in your network place.
I must state I did not create this script and can't take any credit for it. I found it in the forums, so the full credit should go to it's author who I can't remember. As I've now moved on to trying to use .NET to do it.
I've also included some script below which removes the web folder from the network places, it's a modified version of the first script. Hope you find it useful.
Will post back if I make any advances.
******************************* Code *******************************
Option Explicit
Sub CreateNetworkFolder(siteURL, siteName)
Dim iRes, jRes, MT, TT Dim SH, newPath Dim objFso, f, fs, g Dim bString Dim ltrIndex, nameLength, urlLength Dim aFile 'ForWriting (2) is the attribute to be set when writing to a file. Const ForWriting = 2 nameLength = Len(siteName)
urlLength = Len(siteURL)
MT = "OK to create a My Network Places " & vbCr & "folder for " & siteURL & vbCr & "named " & siteName & "?" TT = "My Network Places" iRes = MsgBox(MT, vbOKCancel + vbInformation, TT ) Set objFso = CreateObject("Scripting.FileSystemObject")
If iRes = vbCancel Then WScript.Quit End If Set SH = WScript.CreateObject("WScript.Shell")
'Create the folder under NetHood that will hold the target.lnk file newPath = SH.SpecialFolders("NetHood") & "\" & siteName If (objFso.FolderExists(newPath)) Then WScript.Echo "A Network Place with that name already exists." WScript.Quit End If objFso.CreateFolder(newPath)
'We ceate a Desktop.ini file Set fs = CreateObject("Scripting.FileSystemObject") aFile = newPath & "\Desktop.ini" Set f = fs.OpenTextFile( aFile, ForWriting, True )
'Write the data lines that will make this a folder shortcut. f.WriteLine "[.ShellClassInfo]" f.WriteLine "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" f.WriteLine "Flags=2" f.WriteLine "ConfirmFileOp=0" f.Close 'We make Desktop.ini a system-hidden file by assigning it attribute of 6 Set fs = CreateObject("Scripting.FileSystemObject") Set g = fs.GetFile(newPath & "\Desktop.ini") g.Attributes = 6 'We make the folder read-only by assigning it 1. Set fs = CreateObject("Scripting.FileSystemObject") Set g = fs.GetFolder(newPath) g.Attributes = 1 'This is where we construct the target.lnk file byte by byte. Most of the lines are shown in 16 byte chunks, 'mostly because that is the way I saw it in the Debug utility I was using to inspect shortcut files. 'Line 1, 16 bytes bString = Chr(&H4C) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H14) & Chr(&H02) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&HC0) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'Line 2, 16 bytes bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H46) & Chr(&H81) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'Line 3, 16 bytes bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'Line 4., 16 bytes. 13th byte is significant. bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'Line 5. 13th byte is significant. bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'When I was analyzing the next byte of shortcuts I created, I found that it is set to various values, 'and I have no idea what they are referring to. In desperation I tried substituting some values. '00 caused a crash of Explorer. FF seeems to work fine for all. 'If anyone can get back to me on what this byte is or why FF works, please contact me. bString = bString & Chr(&HFF) bString = bString & Chr(&H00) & Chr(&H14) & Chr(&H00) 'Line 6, 16 bytes bString = bString & Chr(&H1F) & Chr(&H50) & Chr(&HE0) & Chr(&H4F) & Chr(&HD0) & Chr(&H20) & Chr(&HEA) & Chr(&H3A) & Chr(&H69) & Chr(&H10) & Chr(&HA2) & Chr(&HD8) & Chr(&H08) & Chr(&H00) & Chr(&H2B) & Chr(&H30)
'Line 7, 16 bytes bString = bString & Chr(&H30) & Chr(&H9D) & Chr(&H14) & Chr(&H00) & Chr(&H2E) & Chr(&H00) & Chr(&H00) & Chr(&HDF) & Chr(&HEA) & Chr(&HBD) & Chr(&H65) & Chr(&HC2) & Chr(&HD0) & Chr(&H11) & Chr(&HBC) & Chr(&HED)
'Line 8, 16 bytes bString = bString & Chr(&H00) & Chr(&HA0) & Chr(&HC9) & Chr(&H0A) & Chr(&HB5) & Chr(&H0F) & Chr(&HA4) & Chr(&H00) & Chr(&H4C) & Chr(&H50) & Chr(&H00) & Chr(&H01) & Chr(&H42) & Chr(&H57) & Chr(&H00) & Chr(&H00)
'Line 9, 16 bytes bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H10) & Chr(&H00)
'Line 10, 2 bytes bString = bString & Chr(&H00) & Chr(&H00) 'The next byte represents the length of the site name. bString = bString & Chr(nameLength) 'Take the site name, and write each letter, preceeded by a "00" character.
For ltrIndex = 1 to nameLength bString = bString & Chr(&H00) & Mid(siteName, ltrIndex, 1) Next 'Middle line, separates the Folder Name from the URL. 3 bytes. bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) bString = bString & Chr(urlLength) 'Take the site URL, and write each letter, preceeded by a "00" character. For ltrIndex = 1 to urlLength bString = bString & Chr(&H00) & Mid(siteURL, ltrIndex, 1) Next 'Last line, 13 bytes bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)
'Let's create the target.lnk file. Set fs = CreateObject("Scripting.FileSystemObject") aFile = newPath & "\target.lnk" Set f = fs.OpenTextFile(aFile, ForWriting, True) f.Write bString f.Close MT = siteName & " created." jRes = MsgBox(MT, vbOK, TT ) End Sub
CreateNetworkFolder "http://ServerName/webDAV", "Network Place name"
******************************* Code *******************************
******************************* Code ******************************* Option Explicit
Sub RemoveNetworkFolder(siteName)
Dim iRes, jRes, MT, TT Dim SH, newPath Dim objFso, f, fs, g Dim bString Dim ltrIndex, nameLength, urlLength Dim aFile 'ForWriting (2) is the attribute to be set when writing to a file. Const ForWriting = 2 nameLength = Len(siteName)
MT = "OK to delete a My Network Places named " & siteName & "?" TT = "My Network Places" iRes = MsgBox(MT, vbOKCancel + vbInformation, TT ) If iRes = vbCancel Then WScript.Quit End If Set objFso = CreateObject("Scripting.FileSystemObject")
Set SH = WScript.CreateObject("WScript.Shell")
'Create the folder under NetHood that will hold the target.lnk file newPath = SH.SpecialFolders("NetHood") & "\" & siteName If Not (objFso.FolderExists(newPath)) Then WScript.Echo siteName & " does not exists." WScript.Quit End If 'We make the folder normal by assigning it 0. Set fs = CreateObject("Scripting.FileSystemObject") Set g = fs.GetFolder(newPath) g.Attributes = 0 'We make Desktop.ini a normal file by assigning it attribute of 0 'Set fs = CreateObject("Scripting.FileSystemObject") Set g = fs.GetFile(newPath & "\Desktop.ini") g.Attributes = 0 objFso.DeleteFolder(newPath)
MT = siteName & " deleted." jRes = MsgBox(MT, vbOK, TT ) End Sub
RemoveNetworkFolder "Network Place name" ******************************* Code ******************************* Derek Feagin wrote:
Could you please share the script that allows you to create a web
folder in
My Network Places? That is exactly what we are looking for.
Thnaks, Derek <mia_cid@xxxxxxxxxxx> wrote in message news:1111572701.098301.216580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHi all,
On my desktop I'm running XP Pro SP2 and I've got some script that creates a web folder in My Network Places with a name I specify.
What
I'd now like to do is map that to a drive.
So I currently have a folder called webDAV that links to http://server/webDAV/
And I'd like to know if it's possible to assign a drive letter to webDAV or even better straight to http://server/webDAV/
Any help would be greatly appreciated
Just ask if you like any more info or I haven't made sense!
8-)
.
- References:
- Re: map web folder
- From: mia_cid
- Re: map web folder
- Prev by Date: Re: Any idea where the actual "Jim Warrington - wsh utilities and scripts" site is?
- Next by Date: Re: map web folder
- Previous by thread: Re: map web folder
- Next by thread: Re: map web folder
- Index(es):
Relevant Pages
|
Loading