Just run cmd.exe and put quotes around the cmd file name.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to run a cmd file through powershell. The file is located in a folder inside Program Files.
I have tried
invoke-item -path "c:\program files\myProgram\myfile.cmd" which gave me cmd file not found message.
Then, I tried to put that in variable and pipe it to cmd
$myvariable = "c:\program files\myProgram\myfile.cmd"
$myvariable | cmd
That gave an error "'C:\Program' is not recognized as an internal or external command". Apparently, the space in the string there is a problem.
Next, I tried to cd to "c:\program files\myProgram" and then run cmd /c myfile.cmd. Now that seems to work except the powershell does not stop and has to be manually stopped.
Any suggestions as to how to run that cmd from within powershell script? When run from command prompt (elevated privilege) it works fine.
Just run cmd.exe and put quotes around the cmd file name.
Hi Sir,
I am trying to install the Docker Desktop in the VM using CMD in powershell.
It's asking for press OK but it's manual process manually click on OK.
So can you please help to give Auto Answer OK/Yes to install Docker Desktop without manual intervention?
PFB reference article for commands: [https://docs.docker.com/desktop/install/windows-install/