Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Commandline Parameters #195

Open
hb02 opened this issue Jan 12, 2023 · 1 comment
Open

Parsing Commandline Parameters #195

hb02 opened this issue Jan 12, 2023 · 1 comment

Comments

@hb02
Copy link

hb02 commented Jan 12, 2023

Hello

First of All, Big thanks for you tool. It is an awesome type of software.

I think there is an unexpected Behavior starting sccmclictr via commandline and " (Double Quote).

I am starting your tool via Commandline (cmd):
"SCCMCliCtrWPF.exe" test /Username:.\Test /password:Te"st6

this results in an Error "Unable to Connect". For debugging perpose I added an plaintext Lable besides the pb_Passwort-Textbox. The result is:

Test6

The double-quote is gone. So I tried an Username with " --> Result: nothing is parsed.

If I Escape the " via " --> Password is correctly enterd.

Probably this is an Issue with GetCommandLineArgs (https://learn.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?view=net-7.0) and DoubleQuotes.

Kind Regards

@hb02
Copy link
Author

hb02 commented Jan 12, 2023

A probably solution could be changing the parsing of the commandline arguments.

Without great thinking and not changing to much on your professional code:

  • Got the full Commandline
  • Parsing via quick and dirty regex and only using MatchingGroup 1
  • If we got an DoubleQuote take my parsed Password else take you default aproach

`
//Quick and Dirty fix for DoubleQuote
string cmdLine = Environment.CommandLine;
string myPWD = null;
Regex regex = new Regex(@"/password:(\S*)", RegexOptions.IgnoreCase);
foreach(Match m in regex.Matches(cmdLine))
{
int i = m.Index;
Group g = m.Groups[1];
myPWD = g.Value;
}

                    if (myPWD.Contains('"'))
                    {
                        sPW = myPWD;
                    }
                    else
                    {
                        sPW = sPW.Substring(10);
                    }

`

Compiled it as Debug and will give it a try.

Edit: added "RegexOptions.IgnoreCase"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant