-1

Example of my usage ,

Private Sub btntransfer_Click(sender As Object, e As EventArgs) Handles btntransfer.Click
    Process.Start("C:\Windows\System32\migwiz.lnk")
End Sub

These are working but when I want to use this windows applications"RecoveryDrive.exe , rstrui.exe , resmon.exe , dfrgui.exe " debugging is give me error.

Error : Unhandled Exception: System.ComponentModel.Win32Exception: The system cannot find the file specified at

System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at

System.Diagnostics.Process.Start() at

System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

How can I use these programs in my windows application form?

Ganesh R.
  • 4,337
  • 3
  • 30
  • 46
ArdaZeytin
  • 1,324
  • 3
  • 13
  • 21
  • 1
    What is the exception message? – Sriram Sakthivel Dec 31 '13 at 10:24
  • 1
    Also try to use [File.Exists](http://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1). Also similar question exist [here](http://stackoverflow.com/questions/6141821/run-application-via-shortcut-using-process-start-c-sharp) – huMpty duMpty Dec 31 '13 at 10:28
  • File.Exists. working well but it couldn't solved my problem. Thanks. – ArdaZeytin Jan 01 '14 at 11:19

1 Answers1

0

You will need to mention the path of those executables.

For migwiz.lnk, you mentioned the full path as C:\Windows\System32\migwiz.lnk. Try the other executables with thier full paths. It should work.

Try this:

using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        ProcessStartInfo pi = new ProcessStartInfo("rstrui.exe");
        pi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System);

        Process p = new Process();
        p.StartInfo = pi;

        p.Start();
    }
}

Converted to VB.NET using online converter:

Sub Main()

    Dim pi As New ProcessStartInfo("rstrui.exe")
    pi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System)

    Dim p As New Process()
    p.StartInfo = pi

    p.Start()

    'Uncomment the line below if you want your application to wait for the launched application to exit
    'p.WaitForExit()

End Sub

Make sure that the application is set to be built in AnyCPU. (This is because rstui.exe is present in C:\Windows\System32 and not C:\Windows\SysWow64 which is the redirected systems folder for x86 applications)

Ganesh R.
  • 4,337
  • 3
  • 30
  • 46
  • I'm giving redline at bottom of p , pi . How can i use this code ? – ArdaZeytin Jan 01 '14 at 11:35
  • @Zeysoft I have updated my answer to show the entire test console application code I used. The redline means intellisense is warning you that there are errors in your code. In this specific case, it is not able to resolve in which namespace ProcessStartInfo lies. It lies in the System.Diagnostics namespace. Also note this is a C# example. – Ganesh R. Jan 01 '14 at 12:40
  • This code solved my error but some exe s didn't work yet. They doesn't start to work. – ArdaZeytin Jan 02 '14 at 06:48
  • @Zeysoft You will need to figure out where these executables are present and then you may need to data drive your exe such that it launches the correct exe with the correct path. – Ganesh R. Jan 02 '14 at 15:12