' ' ************************************************************************************ ' * ' * NetHood - This creates shortcuts in the logged on user's My Network Places folder ' * John Holliday - 07/23/2005 - 1.0 ' * ChangeAuthorName - DateOfChange - IteratedVersionNumber ' * ' ************************************************************************************ ' Option Explicit ' Declare global objects - these are REQUIRED for all scripts! Public gobjFSO Public gobjWshShell Public gobjWshNet Public gobjSysEnv ' Declare global string variables Public gstrUserNetHood ' Declare global constants Public Const FOR_READING = 1 Public Const FOR_WRITING = 2 ' This ScriptInit sub is REQUIRED for all scripts; it initializes the File System, Shell and Network objects! Sub ScriptInit() Set gobjFSO = CreateObject("Scripting.FileSystemObject") Set gobjWshShell = CreateObject("WScript.Shell") Set gobjWshNet = CreateObject("WScript.Network") Set gobjSysEnv = gobjWshShell.Environment("PROCESS") End Sub Sub CreateCut(lstrFolderName, lstrDescription, lstrTargetPath) ' This sub will create a folder shortcut in the logged on user's My Network Places (NetHood) folder. ' I usually keep the foldername and the description the same, but they can be different. ' The targetpath can be either a UNC path (\\server\share) or a URL (http://www.website.com)! Dim lstrIniFile, lstrLinkFile, lstrRetVal Dim lobjIniFile, lobjFolderName, lobjLinkFile lstrFolderName = gstrUserNetHood & "\" & lstrFolderName lstrRetVal = FolderStatus(lstrFolderName) If lstrRetVal = "exist" Then Set lobjFolderName = gobjFSO.GetFolder(lstrFolderName) lobjFolderName.Attributes = 0 gobjFSO.DeleteFolder(lstrFolderName) Set lobjFolderName = Nothing End If lstrIniFile = lstrFolderName & "\Desktop.ini" lstrLinkFile = lstrFolderName & "\target.lnk" gobjFSO.CreateFolder(lstrFolderName) Set lobjIniFile = gobjFSO.OpenTextFile(lstrIniFile, FOR_WRITING, True) lobjIniFile.WriteLine "[.ShellClassInfo]" lobjIniFile.WriteLine "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" lobjIniFile.WriteLine "Flags=2" lobjIniFile.WriteLine "ConfirmFileOp=0" lobjIniFile.Close Set lobjIniFile = Nothing Set lobjIniFile = gobjFSO.GetFile(lstrIniFile) lobjIniFile.Attributes = 6 Set lobjFolderName = gobjFSO.GetFolder(lstrFolderName) lobjFolderName.Attributes = 1 Set lobjLinkFile = gobjWshShell.CreateShortcut(lstrLinkFile) lobjLinkFile.Description = lstrDescription lobjLinkFile.TargetPath = lstrTargetPath lobjLinkFile.Save End Sub Function FolderStatus(lstrFolderName) Dim lstrExistMsg If (gobjFSO.FolderExists(lstrFolderName)) Then lstrExistMsg = "exist" Else lstrExistMsg = "notexist" End If FolderStatus = lstrExistMsg End Function Sub GetSpecFolds() ' This sets the Current Users info gstrUserNetHood = gobjWshShell.SpecialFolders("NetHood") End Sub Sub SetupSystem() CreateCut "Test One FolderName", "Test One Description", "\\Server\Share" CreateCut "Test Two FolderName", "Test Two Description", "http://www.website.com" End Sub ' Script processing starts here ScriptInit GetSpecFolds SetupSystem WScript.Quit