Can anyone help me to create a Windows batch script equivalent of Windows PowerShell script that I wrote. I know what first few lines should be, but I am not sure for the rest.
PowerShell Code:
Get-Process -Name Firefox | Stop-Process
Start-Process -FilePath "C:\Program Files\Mozilla Firefox\uninstall\helper.exe" -ArgumentList "-ms" -ErrorAction SilentlyContinue -PassThru | Wait-Process -Timeout 30
Start-Process -FilePath "C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe" -ArgumentList "-ms" -ErrorAction SilentlyContinue -PassThru | Wait-Process -Timeout 30
$UserProfiles = Get-ChildItem -Path "C:\Users" -Exclude "Public", "Default"
foreach ($Profile in $UserProfiles) {
Remove-Item -Path "$Profile\AppData\Roaming\Mozilla\Firefox" -Force -Recurse -ErrorAction SilentlyContinue -Confirm:$false
}
Batch Code:
taskill Firefox
"C:\Program Files\Mozilla Firefox\uninstall\helper.exe" -ms
"C:\Program Files (x86)\Mozilla Firefox\uninstall\helper.exe" -ms
...
I would preferred to use PowerShell but the script won't run on the remote computers because of PowerShell version on those remote computers.
, then write the script to the lowest version of PowerShell in your environment, or write your script to have code segments for each version in your environment, check the version and run that branch. There is zero reason to flip to batch for this, if PowerShell (any version) already exists on hosts. I am not seeing anything in the posted script as being version-specific, other thanWait-Process
. Start-Process has a-wait
switch.powershell -version 2 <Path-to-Script>
, this may need some windows features enabling to accomplish (been a while since I have done this myself). Please note that theversion
switch is only able to accept the value of2
otherwise it will try to run with the latest version.