A
A
Alexey K2020-05-06 19:38:59
Command line
Alexey K, 2020-05-06 19:38:59

How to add an executable file with a long path and spaces with a parameter to the system startup via CMD and reg.exe?

There is a need to add an executable file with a long path and spaces with a parameter to the system startup via CMD and reg.exe. This can be done in the following way:

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "My Program" /t reg_sz /d "%ProgramFiles%\My Program\My Program.exe -parameter" /f

But this command will not work, because. the path is long with spaces and there is a passed parameter.
Here you need to add additional characters "\".
What is the correct way to do this by correcting the above command?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2020-05-06
@alexsupra

Here is the snippet
"%ProgramFiles%\My Program\My Program.exe -parameter"
try to write like this:
"\"%ProgramFiles%\\My Program\\My Program.exe\" -parameter"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question