简体   繁体   English

如何通过单击按钮运行 .exe 文件?

[英]How to run .exe file with button click?

i want to use auth system for my app.我想为我的应用程序使用身份验证系统。 i found auth.gg .我找到了 auth.gg 。 after login I want to run my app with button click.登录后,我想通过单击按钮运行我的应用程序。 i found this.我找到了这个。

    // string str = @"C:\windows\system32\notepad.exe";

   // string str  = @"C:\windows\system32\winamp.exe";


    string str  = @"C:\Documents and Settings\Puru\Desktop\NewsLetter\SendNewsletter.exe";
    Process process = new Process();
    process.StartInfo.FileName = str;
    process.Start();

but if i try to run on different computer location wont be same.但是如果我尝试在不同的计算机位置上运行就不会相同。

and i found this我发现了这个

System.Diagnostics.Process.Start("Application.StartupPath\\example.exe");

and i didnt understand this.我不明白这一点。 Where should i locate example.exe?我应该在哪里找到example.exe?

after all i want to make, 1-user will run auth 2-after pass auth system will click button and second .exe file will open毕竟我想制作,1-user 将运行 auth 2-pass auth 系统将单击按钮并打开第二个 .exe 文件

If you're using Auth.gg, you should have a class for it where you initialize the constants and then use a function to login.如果您使用 Auth.gg,您应该有一个类,您可以在其中初始化常量,然后使用函数登录。 This can be done from within the application, so my question to you is, why are you doing it from an external application?这可以从应用程序内部完成,所以我对您的问题是,为什么要从外部应用程序执行此操作? Best practice would be to have the login in the same executable.最佳做法是在同一个可执行文件中登录。

If you so dearly want to do it from an external program, you could always use what you supplied.如果您非常想从外部程序执行此操作,您可以随时使用您提供的内容。

You should then use it like so:然后你应该像这样使用它:

System.Diagnostics.Process.Start("Application.StartupPath\\example.exe"); // Folder containing your program, where example.exe is located

So you can place "example.exe" in the same folder as the application you just ran for the login.因此,您可以将“example.exe”与刚刚运行的用于登录的应用程序放在同一文件夹中。 Replace "example.exe" with the name + extension of your other program that login is supposed to launch.将“example.exe”替换为登录应该启动的其他程序的名称+扩展名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM