How do I get the command-line arguments of a Windows service?

I'm looking for a way to figure out the command-line arguments of any Windows service.

For a non-service process, the command-line arguments can be found in the Windows Task Manager, or programmatically by using WMI as shown in this post.

Unfortunately, these two solutions don't work for a Windows service that is started by the ServiceController.Start(String[] args) method. Both of them show only the executable file path on the command-line, even though some arguments were passed in.

  1. What is the difference между двумя сценариями (услуга vs. процесс, не связанный с обслуживанием)?
  2. Есть ли способ выяснить аргументы Служба Windows?

Я также пробовал создать простую службу, которая просто записывает все аргументы командной строки в журнал событий. Я запустил его с помощью «sc.exe start » и убедился, что не был записан в журнал событий.

Однако ни один из решения сработали для меня. Я пока видел только путь к исполняемому файлу. Моя версия ОС - Windows Server 2008 R2 SP1 x64 Enterprise.

6
задан Peter Mortensen 22 March 2019 в 20:15
поделиться