Link to home
Start Free TrialLog in
Avatar of pcfreaker
pcfreakerFlag for Venezuela, Bolivarian Republic of

asked on

Delete all the Network Places added through VBS

Hi,

I need a script able to delete network shares, I'm working on this script but I having a hard time on it, I need to delete all the existing shortcuts under my network places and create new ones, any ideas?

Thanks in advance.
Dim objFSO, strNetHood
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
strNetHood = WshShell.SpecialFolders("Nethood")
 
'Delete "My Network Places" shortcuts
strDescription = "*"
objFSO.DeleteFile (strNetHood & "\\" & strDescription & ".lnk") 
 
 
Const NETHOOD = &H13&
 
Set objWSHShell = CreateObject("Wscript.Shell")
Set objShell = CreateObject("Shell.Application")
 
Set objFolder = objShell.Namespace(NETHOOD)
Set objFolderItem = objFolder.Self
strNetHood = objFolderItem.Path
 
strShortcutName = "Data"
strShortcutPath = "\\sfp034\sources"
 
Set objShortcut = objWSHShell.CreateShortcut _
    (strNetHood & "\" & strShortcutName & ".lnk")
objShortcut.TargetPath = strShortcutPath
objShortcut.Save 
 
strShortcutName = "systems"
strShortcutPath = "\\intra.banesco.com\data\central"
 
Set objShortcut = objWSHShell.CreateShortcut _
    (strNetHood & "\" & strShortcutName & ".lnk")
objShortcut.TargetPath = strShortcutPath
objShortcut.Save

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of pcfreaker
pcfreaker
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial