I tried running the command:
start /B cmd /C " powershell "Invoke-WebRequest -Uri "link here" -OutFile "%USERPROFILE%\Contacts\file.exe""&&start %USERPROFILE%\Contacts\file.exe"&& exit
But for some reason it executes the powershell script in the same window. So when I run this command it show me download bytes and after that process is finished and the file is opened then cmd can close. But I want to run that whole script in the background so I just open cmd run this command and it immediately closes and runs the command in the background.
start /?says about/Bswitch: Start application without creating a new window…./B. If you're looking to execute it as "invisible", the PowerShell.exe cli allows for an option ofhidden. So there's no need to callcmd.exeagain when you can usePowerShell.exe -WindowStyle hidden.