With this method you can create a shortcut that its “Run as administrator” property is set:
first, you need to add a reference to the "Windows Script Host Object Model" library, it is a COM library, so in the project, right-click on the reference go to the COM section, and add the library.
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using IWshRuntimeLibrary;
class Solution
{
static void CreateShortcut(string shortcutPath, string sourcePath, bool runAsAdmin, params string[] args)
{
var shortcut = new IWshShell_Class().CreateShortcut(shortcutPath) as IWshShortcut;
shortcut.TargetPath = System.IO.Path.GetFullPath(sourcePath);
shortcut.Arguments = "\"" + string.Join("\" \"", args) + "\"";
shortcut.Save();
if (runAsAdmin)
using (var fs = new FileStream(shortcutPath, FileMode.Open, FileAccess.ReadWrite))
{
fs.Seek(21, SeekOrigin.Begin);
fs.WriteByte(0x22);
}
}
static void Main(string[] args)
{
CreateShortcut(Directory.GetCurrentDirectory() + "\\" + "shortcutName" + ".lnk", @"C:\...... path to file ... .exe", true);
}
}
Credit for run as admin section belongs to here