Jump to content

VBScript "WshShell.CreateShortCut"


Recommended Posts

Windows Vista and UAC mean that some of the programs that I have need to be run with Administrator priviledge elevation, this can be done, either by changing the .exe permission to be "always Run as Administrator", right click on the exe and choose run as admin or have a shortcut and set the property of the shortcut to "Run As Admin".

I am creating shortcuts for these programs using VBScript. Windows Vista has an additional property tab for shortcuts (.lnk) labelled Compatibility. there is a tick box on there that will Run the target program as administrator.

What I am asking here: Is there a way to create a shortcut with this tick box enabled within VBScript ??

I can post details of the script that creates the shortcut if need be, but its just a standard vbscript file.

Link to comment
Share on other sites


I use this script:

Dim Act,colEnvironmentVariables, objShortCut, Shell
Set Shell = CreateObject("WScript.Shell")
Set colEnvironmentVariables = Shell.Environment("Volatile")
Set Act = CreateObject("Wscript.Shell")

Set objShortCut = Shell.CreateShortcut(Act.ExpandEnvironmentStrings("%UserProfile%\Desktop\Windows Media Player.lnk"))
objShortCut.TargetPath = Act.ExpandEnvironmentStrings("%ProgramFiles%\Windows Media Player\wmplayer.exe")
objShortCut.Arguments = " /prefetch:1"
objShortCut.WorkingDirectory = Act.ExpandEnvironmentStrings("%ProgramFiles%\Windows Media Player")
objShortCut.Description = "Play digital media including music, videos, CDs, and DVDs."
objShortCut.Save

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...