Process.Start()
only seems to work on a shortcut whose the target is located in the Program Files (x86)
folder and not in the Program Files
folder.
If the target is in the Program Files
folder I get the fallowing error
"The system cannot find the file specified" (run-time error)
Why does this happen, and is there any way to fix this so I can open shortcuts whose targets are in the Program Files
folder.
If it matters - I have Windows 7 Ultimate
Edit
Here is my code
public class MainClass
{
static void Main()
{
Process.Start(Path.Combine(Directory.GetCurrentDirectory(), "Blender") );
Console.ReadLine();
}
}
Edit 2 - My Solution
I've come to suspect the problem was with my IDE(Xamarin Studio). So I installed Visual studio, turned off prefer 32 bit and set it to AnyCPU and it worked. I don't know why Xamarin Studio was doing to cause this problem, but I know visual studio made it go away.
This is a 32-bit issue OR a file location issue.
What have you tried so far?
What code do you use?
I have created a very basic app and it runs just fine, though If I use the wrong path will throw your error. Also using the "prefer 32-bit" will.
Since there's 2 most likely causes you need to do these:
Under "Build" there is a "Platform Target". Be sure it is set to Any CPU and uncheck the "Prefer 32-bit" box.
That will most likely be your issue.
Though you may be saying "I most certainly do not! It's on my desktop! I can see it!" You'd be wrong.
The shortcut can be placed in everyone's desktop by placing it in the public location. For example I have a shortcut on my dessktop but it's not found under my desktop. It appears on my desktop because it's in the public folder.
So Right click the shortcut and use the path listed beside "Location". This is its true location.
Example:
Process.Start(new ProcessStartInfo()
{
FileName = @"C:\Users\Public\Desktop\Oracle VM VirtualBox"
});
Or simply:
Process.Start(@"C:\Users\Public\Desktop\Oracle VM VirtualBox");