以下の内容はhttps://takuya-1st.hatenablog.jp/entry/2024/06/12/000000より取得しました。


PowerShell で確認Y/Nをスキップする

Remove-Item で確認が出る。

例えば、Powershellレジストリを消そうとすると。

レジストリの削除

Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Classes\Directory\background\shell\VSCode' 

確認が表示される。

If you continue, all children will be removed with the item. Are you sure you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

確認無しで削除を実行

確認が表示されると自動化に困難なので、確認を出さない

Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Classes\Directory\background\shell\VSCode'  -Confirm:$false  -Recurse -Force

コレで、確認無しで削除を実行できる。

-confirm:$falseで「無」確認で実行できる。

Bashなどのスクリプトにある「常にYESと答える。」、PowerShellは、Bashとは違い、「はじめから確認なし」になる。

参考資料

https://stackoverflow.com/questions/4753702/automatic-confirmation-of-deletion-in-powershell




以上の内容はhttps://takuya-1st.hatenablog.jp/entry/2024/06/12/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14