[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1163
  • Last Modified:

need to run .exe files located in system32

I need to run a couple of .exe apps that are located in the system32 directory.  When I use this code to run them:

Process process = new Process();
process.StartInfo.FileName = "mstsc.exe";
process.StartInfo.WorkingDirectory = Environment.SystemDirectory;
process.Start();

I get this error: "An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll
Additional information: The system cannot find the file specified"

I have verified the files are there and not hidden or anything goofy, I have the correct file permissions for the folder as well.
0
etekrony
Asked:
etekrony
  • 2
1 Solution
 
jong3Commented:

Try using the static alternative...

Process.Start(Environment.SystemDirectory + "\\mstsc.exe");
0
 
etekronyAuthor Commented:
Same error:  "The system cannot find the file specified"
0
 
Daniel Van Der WerkenIndependent ConsultantCommented:
This absolutely works for me:
using System;
using System.Diagnostics;

namespace runmstsc
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
      {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                  Process process = new Process();
                  process.StartInfo.FileName = "mstsc.exe";
                  process.StartInfo.WorkingDirectory = Environment.SystemDirectory;
                  //Console.WriteLine("System Directory is {0}\n", process.StartInfo.WorkingDirectory.ToString());
                  process.Start();
            }
      }
}

Is MSTSC.EXE dependent upon any other binary file that you do NOT have available?  Can you check that?  What if you do a Start | Run | mstsc from the start menu?  Does that work?

check your path with the commented-out Console.WriteLine() I'm using there.

---Dan---
0
 
etekronyAuthor Commented:
Figured out the problem, now i really don't know how to fix it.

It works great on XP 32-bit, but I am running XP 64-bit.  Seems to be the issue.  Do not know why, the directory is being displayed correctly.

Dan, since you got me going down the right path, you get the points.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now