Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6703605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:11:29+00:00 2026-05-26T07:11:29+00:00

We have a 3rd party login dialog which will skip the login prompt if

  • 0

We have a 3rd party login dialog which will skip the login prompt if the login data is passed in via command line arguments. This is used when an application is launched from within the main 3rd party software.

The custom app I am writing should provide users with a button to change their login info, however since the app is launched with the login info provided in the command line args, the login dialog never appears when the button is clicked.

Is it possible to clear or reset Environment.GetCommandLineArgs() from the code?

Edit

I ended up simply restarting the application prior to startup if login info existed in the command line. This makes the 3rd party login dialog actually show up instead of automatically using the login info provided in the command line arguments.

I’m accepting Jim’s answer because I feel it is the most complete answer to my question, although Oded’s answer is also a viable alternative.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:11:29+00:00Added an answer on May 26, 2026 at 7:11 am

    What you’re asking can’t be done in .NET because the Environment class caches the command line and there’s no property accessor for setting it. (More correctly, the startup code caches the command line and Environment.CommandLine calls into the runtime to get that cached value.)

    In a native Windows application, the GetCommandLine() API function returns a pointer to the command line that the operating system presented to the program. A program can call CommandLineToArgvW to parse the command line into the standard argv and argc parameters familiar to C and C++ programmers.

    The Environment class uses something similar. When you call Environment.GetCommandLineArgs, it accesses the Environment.CommandLine property and then calls the windows function CommandLineToArgvW to parse the command line. But Environment.CommandLine doesn’t get its value from GetCommandLine(). Instead, the program gets the Windows command line at startup (by calling GetCommandLine()), and then saves it.

    This is unfortunate, because you can modify the value that GetCommandLine returns, as demonstrated by this little snippet:

    [DllImport("kernel32")]
    static extern IntPtr GetCommandLine();
    
    static void DoIt()
    {
        IntPtr pcmdline = GetCommandLine();
        Console.WriteLine("Environment.CommandLine = {0}", Environment.CommandLine);
        string realCmdLine = Marshal.PtrToStringAnsi(pcmdline);
        Console.WriteLine("realCmdLine = {0}", realCmdLine);
    
        Console.WriteLine("** Modify command line");
        // Modify the command line
        byte[] bytes = Encoding.ASCII.GetBytes("ham and swiss on rye\0");
        Marshal.Copy(bytes, 0, pcmdline, bytes.Length);
    
        Console.WriteLine("Environment.CommandLine = {0}", Environment.CommandLine);
        pcmdline = GetCommandLine();
        realCmdLine = Marshal.PtrToStringAnsi(pcmdline);
        Console.WriteLine("realCmdLine = {0}", realCmdLine);
    }
    

    If you run that, you’ll find that Environment.CommandLine returns the same string both times, whereas the second time you call GetCommandLine, you’ll get back the string ham and swiss on rye.

    Even if the above did work, there’s no guarantee that it would solve your problem. The 3rd party control might parse the command line, cache the login information, and never parse the command line again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3rd party libraries for my mac applications which used to link nicely
I have a website written in-house, using a 3rd party login mechanism. Recently we've
I have a problem of thinking of how to integrate 3rd party login (also
I am using a 3rd party WinForms Login Dialog in my WPF app, and
I have a 3rd party XLL addin I'd like to wrap in my own
I have a 3rd Party tool that generates an xml spreadsheet (*.xls). I have
I have a 3rd party JAR that I have converted to an OSGI bundle
I have some 3rd party libraries and includes (I have copied them to the
I have a 3rd party ActiveX control I want to render within other presentation
I have a 3rd party struct that is comprised of the following: [StructLayout(LayoutKind.Sequential, Size=1)]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.