Option Explicit
Dim FSO : Set FSO = Createobject("Scripting.FileSystemobject")
Dim Shell : Set oShell = WScript.Createobject("WScript.Shell")
Dim AllUsersProfile : AllUsersProfile = Shell.ExpandEnvironmentStrings("%AllUsersProfile%")
Dim Target
Hi,
Can someone tell if this code is correct, I think it may be wrong. To start I want to delete an existing folder (and its shortcut inside of it) from the Windows 7 Programs menu. It appears at one time while messing with the code it deleted the shortcut, but not folder. Now I am getting some variable undefined error.
Target = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office Tools"
If fso.FolderExists(target) Then
fso.DeleteFolder target
End If
Set ShellLink = oShell.CreateShortcut(AllUsersProfile & "\Microsoft\Windows\Start menu\Programs\Microsoft Office 2010 Tools\Snapshot Viewer.lnk")
oShellLink.TargetPath = "C:\Program Files (x86)\Snapshot Viewer"
oShellLink.WorkingDirectory = "C:\Program Files (x86)\Snapshot Viewer"
oShellLink.IconLocation = icon
oShellLink.Save
Thank you.
Dim FSO : Set FSO = Createobject("Scripting.FileSystemobject")
Dim Shell : Set oShell = WScript.Createobject("WScript.Shell")
Dim AllUsersProfile : AllUsersProfile = Shell.ExpandEnvironmentStrings("%AllUsersProfile%")
Dim Target
Hi,
Can someone tell if this code is correct, I think it may be wrong. To start I want to delete an existing folder (and its shortcut inside of it) from the Windows 7 Programs menu. It appears at one time while messing with the code it deleted the shortcut, but not folder. Now I am getting some variable undefined error.
Target = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office Tools"
If fso.FolderExists(target) Then
fso.DeleteFolder target
End If
Set ShellLink = oShell.CreateShortcut(AllUsersProfile & "\Microsoft\Windows\Start menu\Programs\Microsoft Office 2010 Tools\Snapshot Viewer.lnk")
oShellLink.TargetPath = "C:\Program Files (x86)\Snapshot Viewer"
oShellLink.WorkingDirectory = "C:\Program Files (x86)\Snapshot Viewer"
oShellLink.IconLocation = icon
oShellLink.Save
Thank you.