Software uninstallation - by running batch file

Hello,

I would like to uninstall software - the developer has provided .bat file for the uninstallation. I am getting error while running the software deployment - Not a valid cmd.exe command. Please specify a run option (use /C or /K option) -

Any recommendations to run batch file?

Regards,
Satkumar

What is the command line that you are using currently in the action?

does it look like:
runhidden cmd /K “c:\windows\temp\uninstall.bat”

Hi,

Thank you very much. I was trying to run the batch file as “Uninstall.bat”. But now I have added the command which you have mentioned - “runhidden cmd /K Uninstall.bat”. Now the error is gone and I am able to create the package.

Any recommendation to run a batch file other than software deployment wizard?

Yes. Take a look at the BigFix Developer Reference site for more info on commands you can use in an action.

If it’s a fairly simple script/batch file is or if it’s one that you may want modify frequently you can create the file in the action without having to upload it.

You can use createfile until:

A quick powershell example to search for all .exe files on a system and output to a text file:

delete __createfile
delete c:\windows\temp\exe_search.ps1
delete c:\windows\temp\exe_files.txt
    
createfile until EOF
$drives = Get-WmiObject win32_volume | ? {{$_.DriveType -eq 3} | % {{Get-PSDrive $_.DriveLetter[0]}
foreach ($drive in $drives){{
$path = $drive.root + "*.exe"
cmd.exe /C dir /s /b /a /o:gn $path | out-file -append -filepath c:\windows\temp\exe_files.txt -encoding ASCII
}
    
EOF

copy __createfile c:\windows\temp\exe_search.ps1

runhidden cmd /K powershell.exe -ExecutionPolicy Bypass c:\windows\temp\exe_search.ps1

You can also use appendfile :

A quick example to remove java jdk/jre:

delete __appendfile
delete c:\windows\temp\uninstall.bat

appendfile {concatenation "%0d%0a" of ("start /w msiexec /x" & name of it & " /qn REBOOT=ReallySuppress") of keys whose (value "DisplayName" of it as string as lowercase contains "java" AND (value "Publisher" of it as string as lowercase contains "oracle" OR value "Publisher" of it as string as lowercase contains "sun") AND value "DisplayName" of it as string as lowercase does not contain "java auto updater" AND value "DisplayVersion" of it as string as version < "8.0.1810.13") of keys "hklm\software\microsoft\windows\currentversion\uninstall" of (x64 registries;x32 registries)}

copy __appendfile "c:\windows\temp\uninstall.bat"
1 Like