GottaFix for WannaCrypt?
PowerShell 2.0, 24 20 16 bytes
hotfix KB4012212
-4 bytes thanks to @whatever by removing -id
.
-4 bytes thanks to @DankoDurbić by changing get-hotfix
to hotfix
.
KB4012212
is the patch for Windows 7. This can be replaced with any KB-code from the linked page of the patch.
Will return the Source, Description, HotFixID, InstalledBy and InstalledOn information when it's installed as truthy value, and will give an error if it's unable to find it as falsey value.
Here is an example of both a truthy and falsey output (so KB4012212
is installed on my machine, but KB4012215
is not):
Batch / Windows CMD, 31 29 28 23 bytes
wmic qfe|find "4012212"
-1 byte thanks to @SteveFest by changing findstr 4012212
to find "4012212"
.
-5 bytes thanks to @BassdropCumberwubwubwub by removing list
.
Explanation:
wmic Windows Management Instrumentation Command-line
qfe Quick Fix Engineering
|find "..." Looks for the string in the complete output
Outputs some patch info if it's installed, or nothing otherwise.
In the screenshot below, patch 4012212
is installed, and 4012215
is not.
Bash + Cygwin (Or WSL), 21 bytes
This answer is mostly stolen from Kevin's answer. So throw an upvote that way also if you think this deserves one.
wmic qfe|grep 4012212
Cygwin has access to the Windows commands in addition to coreutils. We are able to use coreutils's grep
instead of Windows's find
so we don't need to use quotes. 2 bytes are saved because of this.