I have VS2010, C# program that is setup to build as x86. I have two PCs where they are running. Both are Win 7 Prof, SP1, 32 bits. Both VS2010s are running at Admin level. Within my project I try to execute the line:
Process.Start("c:\\Windows\\System32\\osk.exe"); //win 7 on-screen keyboard
From debug mode-run, on one system it runs fine, on the other, an exception is thrown: The specified executable is not a valid application for this OS platform.
I have the user control setting in Win 7--User Accounts to "never notify" as suggested from other sites, that did not work.
I have tried: (same result, fail)
Process process = new Process();
process.StartInfo.UseShellExecute = false; //have tried it true also
process.StartInfo.WorkingDirectory = "c:\\";
process.StartInfo.FileName = "c:\\WINDOWS\\system32\\osk.exe";
process.StartInfo.Verb = "runas";
process.Start();
Any ideas what needs to be changed (or do)?
Will this work for you? I altered it a bit using the System.Diagnostics.ProcessStartInfo Class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = @"c:\WINDOWS\system32\";
startInfo.FileName = "osk.exe";
startInfo.Verb = "runas";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
try
{
using(Process process = Process.Start(startInfo))
{
process.WaitForExit();
}
}
catch (Exception)
{
//throw;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.