Board index » Visual Studio » delete netplaces shortcut
|
ekaram
|
delete netplaces shortcut
Visual Studio194
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 - |
