private void CreateShortcut()
{
try
{
WshShellClass wshShell = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut;
string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
// Create the shortcut
if (!System.IO.File.Exists(startUpFolderPath + "\\" + Application.ProductName + ".lnk"))
{
shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath + "\\" + Application.ProductName + ".lnk");
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Description = "File Downloader";
shortcut.Save();
}
}
catch (Exception ex) { }
}
{
try
{
WshShellClass wshShell = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut;
string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
// Create the shortcut
if (!System.IO.File.Exists(startUpFolderPath + "\\" + Application.ProductName + ".lnk"))
{
shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath + "\\" + Application.ProductName + ".lnk");
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Description = "File Downloader";
shortcut.Save();
}
}
catch (Exception ex) { }
}
0 Comments