Results 1 to 4 of 4

Thread: execute a "form" from another account

  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Sep 2018
    Posts
    2
    Rep Power
    0

    execute a "form" from another account

    Hello everyone,

    I introduce myself, my name is Greg. I am stuck on an application that we use for "Windows" account creations. I must be able to execute a "form" from another account. When can I do? I thought I would use a "process.startinfo" but I could not indicate the "file" ... thank you for your help.

    here is the code that poses me problem, the "showDialog" option was used before a change of account


    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.Arguments = "";
    proc.StartInfo.Domain = useradmin.Domaine;
    proc.StartInfo.UserName = useradmin.Login;
    proc.StartInfo.Password = useradmin.Password;
    proc.StartInfo.LoadUserProfile = true;

    proc.Start();


    // Application.EnableVisualStyles();
    // Application.SetCompatibleTextRenderingDefault(fals e);
    // Application.Run(new formulaire_1());

    // var application = new formulaire_1();
    // application.ShowDialog();

  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Location
    Norway
    Posts
    429
    Rep Power
    108
    This is the path to the current application: Application.ExecutablePath Property (System.Windows.Forms) | Microsoft Docs

    If you just need to run some code as different user you can use "impersonation", but you probably need to run the process as administrator with elevated privilegies and you need to start a new process for that to happen (with "runas" verb).
    [xcode=c#] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  3. #3
    .NET Framework
    .NET 4.5
    Join Date
    Sep 2018
    Posts
    2
    Rep Power
    0
    Hello,
    Thank you for your answer, however my problem is the following.
    The first "FORM" must be executed with the "user windows current", then in a second time the "FORM2" must be it with a specific user. I tried to set up the "impersonation" without result to date.

  4. #4
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Location
    Norway
    Posts
    429
    Rep Power
    108
    You could pass an argument to the process and read Command-Line Arguments (C# Programming Guide) | Microsoft Docs to conditionally show different forms, or use two different applications.
    [xcode=c#] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

Similar Threads

  1. Question Creating an "attendece form" issues
    By AshleighK in forum C# General Discussion
    Replies: 3
    Last Post: 01-17-2018, 6:13 PM
  2. Replies: 0
    Last Post: 02-23-2017, 9:41 AM
  3. Replies: 0
    Last Post: 02-12-2016, 4:56 AM
  4. Question How to use "CSML" library from CodeProject to Create a Matrix of Complex Numbers?
    By BflatCisSharp in forum Third Party Products
    Replies: 1
    Last Post: 09-03-2015, 11:07 AM
  5. Replies: 0
    Last Post: 06-22-2015, 12:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •