Try
oShellLink.TargetPath = "\\servername\sharename$"
instead of
> oShellLink.TargetPath = "\\servername\sharename$.lnk"
Regards
Ulf
samantha wrote:
> set WshShell = WScript.CreateObject("Wscript.Shell")
> strDesktop = WshShell.SpecialFolders("Desktop")
> set oShellLink = WshShell.CreateShortcut(strDesktop &
> "\\servername.lnk")
> oShellLink.TargetPath = "\\servername\sharename$.lnk"
> oShellLink.Save
oShellLink.TargetPath = "H:\"
Tom Lavedas
============
I think the problem is with this line:
set oShellLink = WshShell.CreateShortcut(strDesktop & "\\servername.lnk")
I think it should be:
set oShellLink = WshShell.CreateShortcut(strDesktop & "\servername.lnk")
Note just one backslash before the shortcut name.
Hope this helps!
Cheers,
Pete
"samantha" wrote:
> I am very new to vbscripting. i have am attempting to map to a
> network share and then create a desktop shortcut to that share. i am
> having trouble placing the shortcut and hope someone can help.
>
> What I have below will map the drive but not create a shortcut:
>
>
> Set objNetwork = WScript.CreateObject("Wscript.Network")
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> If Not oFSO.DriveExists("h:") Then
> objNetwork.MapNetworkDrive "h:", "\\shervername\sharename$"
> End If
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thank you to everyone for your comments. Unfortuantely the script does
not work. The error message is on the last line which attempts to save
the shortcut to the desktop.
If anyone has other ideas i'd be grateful.
----
set WshShell = WScript.CreateObject("Wscript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop &
"\servername\sharename$.lnk")
oShellLink.TargetPath = "l:\"
oShellLink.Save
Sorry, no more ideas. Here's one of mine that makes some shortcuts to shares
etc though, hope it's of use!
on error resume next
Set WshNetwork = WScript.CreateObject("WScript.Network")
set oFileSys= CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
luser = WshNetwork.UserName
ServName = "os_server"
PFtitle = "My Personal Folder"
PFpath = "\\" + ServName + "\PF-" + lUser + "\"
PFdesc = "Open my (" + lUser + ") personal folder on the server (" +
ServName + ")."
SMfolder = "Programs\CDD Applications and Links"
GraphPath = "\\" + ServName + "\GU-Graphics\"
NMpath = "C:\Program Files\NetMeeting\conf.exe"
'------------------------------------------
' Creating shortcuts in My Documents
sfolder = oShell.SpecialFolders("MyDocuments")
If oFileSys.FolderExists(PFpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\" + PFtitle + ".lnk")
oSLink.TargetPath = PFpath
oSLink.Description = PFdesc
oSLink.Save
End If
'------------------------------------------
' Creating shortcuts My Pictures (must follow My Documents links)
If oFileSys.FolderExists(GraphPath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\My Pictures\CDD shared
graphics.lnk")
oSLink.TargetPath = GraphPath
oSLink.Description = "Open the shared graphics folder on the server (" +
ServName + ")."
oSLink.IconLocation = "%SystemRoot%\System32\mydocs.dll,1"
oSLink.Save
End If
'------------------------------------------
' Creating shortcuts on the D: drive
If oFileSys.FolderExists(GraphPath) Then
Set oSLink = oShell.CreateShortcut("D:\Data\Pictures\CDD shared
graphics.lnk")
oSLink.TargetPath = GraphPath
oSLink.Description = "Open the shared graphics folder on the server (" +
ServName + ")."
oSLink.IconLocation = "%SystemRoot%\System32\mydocs.dll,1"
oSLink.Save
End If
'------------------------------------------
' Creating shortcuts on the Desktop
sfolder = oShell.SpecialFolders("Desktop")
If oFileSys.FolderExists(PFpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\" + PFtitle + ".lnk")
oSLink.TargetPath = PFpath
oSLink.Description = PFdesc
oSLink.Save
End If
If oFileSys.FileExists(NMpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\NetMeeting.lnk")
oSLink.TargetPath = NMpath
oSLink.Description = "Use NetMeeting to chat to other users on the network.
You can also use it to view / control remote desktops and share files."
oSLink.Save
End If
'------------------------------------------
' Creating shortcuts on the Send To menu
sfolder = oShell.SpecialFolders("SendTo")
If oFileSys.FolderExists(PFpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\" + PFtitle + ".lnk")
oSLink.TargetPath = PFpath
oSLink.Description = PFdesc
oSLink.Save
End If
'------------------------------------------
' Creating links in the Favourites list
sfolder = oShell.SpecialFolders("Favorites")
Set oSLink = oShell.CreateShortcut(sfolder & "\CDD Intranet Home Page.url")
oSLink.TargetPath = "http://web1/forcenet/?CatID2=970"
oSLink.Save
'------------------------------------------
' Creating links in the Start Menu
sfolder = oShell.SpecialFolders("StartMenu")
If oFileSys.FileExists(NMpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\Programs\NetMeeting.lnk")
oSLink.TargetPath = NMpath
oSLink.Description = "Use NetMeeting to chat to other users on the network.
You can also use it to view / control remote desktops and share files."
oSLink.Save
End If
sfolder = sfolder & "\" & SMfolder
oFileSys.DeleteFolder(sfolder)
oFileSys.CreateFolder(sfolder)
Set oSLink = oShell.CreateShortcut(sfolder & "\CDD Intranet Home Page.url")
oSLink.TargetPath = "http://web1/forcenet/?CatID2=970"
oSLink.Save
If oFileSys.FolderExists(PFpath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\" + PFtitle + ".lnk")
oSLink.TargetPath = PFpath
oSLink.Description = PFdesc
oSLink.Save
End If
If oFileSys.FolderExists(GraphPath) Then
Set oSLink = oShell.CreateShortcut(sfolder & "\CDD shared graphics.lnk")
oSLink.TargetPath = GraphPath
oSLink.Description = "Open the shared graphics folder on the server (" +
ServName + ")."
oSLink.IconLocation = "%SystemRoot%\System32\mydocs.dll,1"
oSLink.Save
End If
'------------------------------------------
'Mapping H: drive to personal folder
If oFileSys.FolderExists(PFpath) Then
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.MapNetworkDrive "H:", PFpath, true
End If
Tom Lavedas
============