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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

removed netplaces shortcut

Status
Not open for further replies.
Jul 27, 2004
397
US
Belowe is a script that creates a shortcut in netplaces to a share. How can
I edit this so it will now remove this shortcut if the user has it?

Set wshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

strNetHood = WshShell.SpecialFolders("NetHood")
strShareName = strNetHood & "\Amarillo JCAHO"
strNetworkPath = "\\amarillodw\Forms"

If Not objFSO.FolderExists(strShareName) Then
CreateFolderShortcut strShareName,strNetworkPath
Else
objFSO.DeleteFile(strShareName & "\Target.lnk")

Set objShortCut = WshShell.CreateShortcut(strShareName & "\Target.lnk")
objShortCut.TargetPath = strNetworkPath
objShortCut.Save
End If

'''''''''''''''''''''''''''''
' Create Folder Shortcut
'''''''''''''''''''''''''''''

sub CreateFolderShortcut(obj,npath)
' Create a folder object
set oFolder = objFSO.CreateFolder(obj)

' Create a target shortcut
set oShellLink = wshShell.CreateShortcut(obj & "\target.lnk")
oShellLink.TargetPath = npath
oShellLink.Save

' Create Desktop.ini file and make it hidden+system
Set oFile = objFSO.CreateTextFile(obj & "\Desktop.ini", True)
oFile.WriteLine("[.ShellClassInfo]")
oFile.WriteLine("CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}")
oFile.WriteLine("Flags=2")
oFile.WriteLine("ConfirmFileOp=0")
oFile.Close
set oAttrib = objFSO.GetFile(obj & "\Desktop.ini")
setattribute oAttrib,6

' Make object read-only
setattribute oFolder,1

end sub


'''''''''''''''''''''''''''''
' Set File/Folder Attributes
'''''''''''''''''''''''''''''

sub SetAttribute(obj,attr)
'mask for read/write attribute bits
' = readonly+hidden+system+archive
rw_bits = 1 + 2 + 4 + 32
oldattr = obj.attributes and rw_bits
newattr = oldattr or attr
obj.attributes = newattr

end sub




Network Admin
A+, Network+, MCSA 2000, MCSE 2000
MCSA (2003)
 
Nobody knows how to do this?

Network Admin
A+, Network+, MCSA 2000, MCSE 2000
MCSA (2003)
 
Nobody knows how to do this?

Maybe I wasn't clear in the description. A shortcut to a share is placed in each user's net places. I have removed the script from running but the shortcut still shows up. I need a script to delete the shortcut. How can I do this?

Network Admin
A+, Network+, MCSA 2000, MCSE 2000
MCSA (2003)
 
>Maybe I wasn't clear in the description
No, you made the effort. Only the forum is not in high-enough spirit recently. Just my assessment.

>How can I edit this so it will now remove this shortcut if the user has it?
You remove a shortcut just like you delete a file with extension lnk. You have already used a line like this in your script:
[tt]objFSO.DeleteFile(strShareName & "\Target.lnk")[/tt]
It "removes" the link.

So what you ask for is already answered in your script.


 
Perhaps this ?
If objFSO.FolderExists(strShareName) Then
objFSO.DeleteFolder strShareName, True
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top