greet !
at first i want to use powershell to generate a cmd and put some command in it
[CmdletBinding()]
param (
[Parameter()]
[string]
$ParameterName
)
cmd /c "start cmd /k " $ParameterName
it work well when i input some prompt without space & 'C:\ex-sys\Program files\dre\dre.ps1' tasklist ,but when the prompt with space like &
'C:\ex-sys\Program files\dre\dre.ps1' 'F:\git hub\yt-dlp\yt-dlp (27).exe'
it output in cmd
'F:\git' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
which mean 'F:\git' isn't command or any runable bat ,Apparently the cmd miss my quote in powershell so is there anyway i could fix this problem
Replace:
with:
This avoids the unnecessary
cmd /ccall and uses embedded"..."quoting (`"...`") around the value of$ParameterNameto ensure thatcmd.exerecognizes it a single argument even if it contains spaces.Start-Processis PowerShell's analog tocmd.exe's internalstartcommand (and in PowerShell there's even astartalias for it).