Question : Getting around Access Denied on Vista/7

Hello.
My app needs to create some shortcut icons and I would prefer them to be on the all users desktop (C:\Users\Public\Desktop). My code works fine if I put it on the users desktop. I know that Public Desktop in Vista/7 is protected but is there anyway I can do this without running the program as admin or changing permissions? Some apps have a pop-up asking for permissions when you run it, is there someway I can use that in my app to have the user decide to run it as elevated?

The message I'm getting is:
System.UnauthorizedAccessException: Access is Denied
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
            Dim WshShell As WshShellClass = New WshShellClass
            Dim allUsersDesktop As String = "AllUsersDesktop"
            Dim shortcutPath As String = WshShell.SpecialFolders.Item(allUsersDesktop).ToString

            shortCut = CType(WshShell.CreateShortcut(shortcutPath & "\" & shortcutName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
            shortCut.TargetPath = targetFullpath
            shortCut.WindowStyle = 1
            shortCut.Description = shortcutName
            shortCut.WorkingDirectory = workingDir
            shortCut.IconLocation = iconFile & ", " & iconNumber
            shortCut.Save()

Answer : Getting around Access Denied on Vista/7

Random Solutions  
 
programming4us programming4us