I am new to PowerShell and a bit confused right now.
Here are two examples which, in my view, are supposed to work the same way. But it seems I am wrong.
Example 1 :
$ Get-Location
Path
----
C:\Users\toto
$ cd .\Dev\nginx-1.22.1\
$ Start-Process .\nginx.exe
$ Get-Process -Name nginx
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
11 1,86 9,25 0,00 8824 5 nginx
13 2,37 9,56 0,00 30068 5 nginx
So everything looks fine.
Example 2 :
$ Get-Location
Path
----
C:\Users\toto
$ Start-Process -FilePath C:\Users\toto\Dev\nginx-1.22.1\nginx.exe
$ Get-Process -Name nginx
Get-Process: Cannot find a process with the name "nginx". Verify the process name and call the cmdlet again.
So, basically, in the first example I first go to the .exe file location and launch it. In the second example, I use absolute path for the .exe file and it does not work. Is it normal ? I guess I miss something about the use of Start-Process or something. I would appreciate any help on this.
After reading the nginx documentation, it seems I have to be in the same location as the
nginx.exefile for it to work properly when I launch it. So my problem was not related to powershell, but to nginx itself. Not very handy but it works!