Win API - how to start desktop programs? [closed]
In the pictire below is my desktop (win7 pro). I want in C# code to start the icon Broadband.lnk
And when i start it to push the button Disconnect shown on this picture
I tried with using System.Diagnostics; but cmd doesnt work... Any ideas how to start the desktop icon and after this to attach to its window and call the button?
I tried with cmd this code and it didnt worked:
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput =
true;
cmd.StartInfo.RedirectStandardOutput =
true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
/* execute "dir" */
cmd.StandardInput.WriteLine(@".\Desktop\Broadband.lnk");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
Use netsh
as detailed in Microsoft KB: Disconnect from a network in Windows Vista and Windows Server 2008 if you want to do this in script, otherwise look at the Win32 APIs on which netsh
is built. And never, ever, ever press buttons on the screen programmatically. People were burned at the stake for less.
May be process.start can help you: http://dotnetperls.com/process-start
精彩评论