开发者

Win API - how to start desktop programs? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago. 开发者_StackOverflow社区

In the pictire below is my desktop (win7 pro). I want in C# code to start the icon Broadband.lnk

Win API - how to start desktop programs? [closed]

And when i start it to push the button Disconnect shown on this picture

Win API - how to start desktop programs? [closed]

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜