This is my code, i need my service to make a shortcut to an application on user desktop if the shortcut not exist. when i debug my application inside visual studio it will put the shortcut on my desktop, but when i run the service on windows it always will put the shortcut on C Drive not on my desktop.
private void CreateShortcut()
{
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
//string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string shortcutAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\CadEisancy.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "New shortcut for a Notepad";
shortcut.Hotkey = "Ctrl+Shift+N";
shortcut.TargetPath = @"C:\RankWindowsApp\RankWindowsApp\bin\Debug\RankWindowsApp.exe";
shortcut.IconLocation = @"C:\RankWindowsApp\Icon.ico";
shortcut.Save();
}
protected override void OnStart(string[] args)
{
//Create Shortcut On Desktop
CreateShortcut();
}
My code:
![MyCode][1]