Passing argument to the application does not work

Jakub Vana 0 Reputation points
2023-07-17T11:09:54.9833333+00:00

Hello,

I found strange behaviour on Windows 11, which caused problems during the application start. I have my own application that accepts some arguments on the input. I have an association in the registry (Computer\HKEY_CLASSES_ROOT\MyApplication.psi\shell\open\command) for starting the application execution (the association is via file extensions).

"C:\Program Files (x86)\ApplicationFolder\MyApplication.exe" -p "%1"

But if I am trying to debug my application (opening the file with a specific extension), the argument -p (path) is not passed inside the Main method of the application, where the arguments can be parsed for the next execution. Only the argument %1 is successfully passed to the input. I do not know why the -p argument is not passed also to the input. Can be somewhere this argument overridden for example by some system/environmental variable or something else?

I was trying to change the -p parameter to"-p" but it did not help. I do not know what to check in the Windows environment to find, where can the argument be overridden or deleted or why it is not passed for the next processing. It is also interesting that in the past it works well on my computer and it stopped working later. So I think it must be caused by some setting.

Thank you very much for your help.

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,666 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,506 Reputation points
    2023-07-19T07:09:34.5666667+00:00

    Use answers to provide solutions to the user's question.Hello there,

    If you are having trouble passing arguments to an application and they are not working as expected, here are a few troubleshooting steps you can follow:

    Check the correct syntax: Ensure that you are using the correct syntax for passing arguments to the application. The syntax can vary depending on the application and the operating system. Review the documentation or help files for the specific application to confirm the proper syntax for passing arguments.

    Use quotation marks: If your argument contains spaces or special characters, enclose the argument in quotation marks. For example, if your argument is "C:\Program Files\MyApp\app.exe," enclose it in quotation marks like this: "C:\Program Files\MyApp\app.exe". This ensures that the argument is treated as a single entity.

    Verify the argument order: Some applications have specific requirements for the order in which arguments should be passed. Make sure you are passing the arguments in the correct order according to the application's documentation.

    Check for argument conflicts: Ensure that there are no conflicts or clashes between the arguments you are passing. Some applications may have reserved or predefined arguments that override the ones you are trying to pass. Review the documentation or help files to check if any conflicts exist.

    Test with different arguments: Try passing different arguments to the application to see if any of them work. This can help determine if the issue is specific to certain arguments or if there is a more general problem with passing arguments

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.