To make my application to start on Windows sturup I decided to put a shortcut to Startup folder.
I tried to use:
File.Move(AppDomain.CurrentDomain.BaseDirectory + "ApplicationName.exe", Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "ApplicationName.lnk");
It works, but it moves my shortcut not to the folder I need.
Environment.GetFolderPath(Environment.SpecialFolder.Startup)
works well, it returns:
C:\Users\Germanov\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
But my shortcut appears in
C:\Users\Germanov\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Just 1 folder "behind".
File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "ApplicationName.lnk");
also works "strange". It actually deletes this file, but again not in "Startup" folder.
If I try to manually add "\Startup" to the path like this:
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"Startup\ApplicationName.lnk"
I get a System.IO.Excseption.
I can't type this path manually, I neen my application to work at diferent PCs with different versions of Windows. I also can't use Registry to make my application start with windows startup.
I use Windows 7, Visual Studio 2010, .NET 4.0, this is a WPF project.
Any ideas?