Can't get a rather simple if exists statement to return true

I’ve been banging my head against a wall with this, and it’s probably something simple I don’t see. Hopefully someone can help me (I know Jason Walker has been very helpful in the past).

I’m doing an if exists statement to see if I can match the existence of VC++ Redistributable installs listed in the registry on a Windows system before I uninstall them. This is all done in action script, not relevancy) since I’m looking for an uninstalling all older VC++ Redistributes from 2008 to 2013. I can easily do this in PowerShell, but I’m trying to force myself to use Action Script more with my tasks. I researched this till my nose bleeds and found many different ways to construct the if exists statement as well as the msiexec command, so I’ll list different ways I have found, and hopefully one will work with some tweaking. I’ve also been using the Fixlet Debugger to help, but it only goes so granular when debugging (by line not character/command/reserved word). In the debugger I keep seeing pop up messages when running my test actions about"completed but “pending a restart” (not sure why?) and then “expression contained a character which is not allowed” when adding curly brackets for relevancy.

if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden msiexec.exe /x {name of key whose (exists values "DisplayName" whose(it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of it) of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)} /qn
endif

I’ve tried…

if exists (value "DisplayName" of it as string starts with "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)

if {exists (value "DisplayName" of it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}

…and many more. I’m using version 9.0.21022 of the 2008 redistribute, but I’ve used others in my testing and confirmed that they actually exist in the registry on the target system or on my own system when testing with Fixlet Debugger. I’ve even tested for installs listed in “HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall” as well. I’ve tried registry, native registry, x32 and x64 registry references, the curly brackets for relevancy statements, and more. Hopefully you guys can steer me in the right direction.

Note: I’m mostly going off of registry values from this helpful blog article: https://zzz.buzz/notes/vc-redist-packages-and-related-registry-entries/

Take a look at this post for inspiration.

If you take out the exists, and evaluate the rest of your relevance:

Q: value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030") of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
E: Singular expression refers to nonexistent object.

Which will always be false because you are looking for a “DisplayName” value for the keys “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”.

You should be looking at the keys that belong to the Uninstall key. (keys of keys)

Q: value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
A: Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030
T: 15.286 ms

Finally:

Q: exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
A: True
T: 10.291 ms

This also works for me:

// Tests for the existence of the key
Q: exists it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030" ) of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
A: False
T: 12.374 ms

// Returns the name of the key in question
Q:  name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030" ) of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
A: {B175520C-86A2-35A7-8619-86DC379688B9}
T: 8.268 ms

// Remove the NUL and return the uninstall string
Q: substring (0, length of it - 1) of (value "uninstallString" of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030" ) of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries) as string)
A: MsiExec.exe /X{B175520C-86A2-35A7-8619-86DC379688B9}
T: 4.235 ms
2 Likes

Thank you! This works for me now in Action Script using the 2010 redistribute as an example:

if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.40219") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}

waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.40219") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}

endif

I have a follow up question regarding 32-bit vs 64-bit registries. Does the x32 registries reference point to the registry path of “HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall”? If so, I assume that I only need to search in the path “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”, correct?

Thanks!

That is correct,
.....keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)
references both key paths

1 Like

Thanks! I’ll ditch the WOW6432Node reference then. :blush:

I’m sharing the commands of my VC++ Redistribute task that’s working well in case anyone was searching for this in the future.

// VC++ 2008 //


//9.0.21022
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//9.0.21022.218
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022.218") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022.218") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022.218") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.21022.218") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//9.0.30411
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30411") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30411") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30411") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30411") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//9.0.30729.17
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.17") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.17") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//9.0.30729.4148
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//9.0.30729.6161
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif


// VC++ 2010 //

//10.0.30319
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.30319") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.30319") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2010  x64 Redistributable - 10.0.30319") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2010  x64 Redistributable - 10.0.30319") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//10.0.40219
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.40219") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2010  x86 Redistributable - 10.0.40219") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2010  x64 Redistributable - 10.0.40219") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2010  x64 Redistributable - 10.0.40219") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif


// VC++ 2012 //

//11.0.61030 Additional Runtime
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//11.0.61030 Minimum Runtime
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x86 Minimum Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x86 Minimum Runtime - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//11.0.61030
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 Redistributable (x86) - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 Redistributable (x86) - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2012 Redistributable (x64) - 11.0.61030") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2012 Redistributable (x64) - 11.0.61030") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif


// VC++ 2013 //

//12.0.21005 Additional Runtime
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//12.0.21005 Minimum Runtime
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//12.0.30501
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.30501") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.30501") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.30501") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.30501") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//12.0.40660
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.40660") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.40660") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40660") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40660") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//12.0.40664 Additional Runtime
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.40664") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.40664") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.40664") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.40664") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif

//12.0.40664
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.40664") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.40664") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif
if {exists value "DisplayName" whose (it as string = "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40664") of keys of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
waithidden "{pathname of system folder & "\msiexec.exe"}" /qn /x{name of it whose (value "DisplayName" of it as string is "Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40664") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)}
endif


// Naming Convention Reference //
//Microsoft Visual C++ 2008 Redistributable - x86
//Microsoft Visual C++ 2008 Redistributable - x64
//Microsoft Visual C++ 2010  x86 Redistributable
//Microsoft Visual C++ 2010  x64 Redistributable
//Microsoft Visual C++ 2012 Redistributable (x86)
//Microsoft Visual C++ 2012 Redistributable (x64)
//Microsoft Visual C++ 2013 Redistributable (x86)
//Microsoft Visual C++ 2013 Redistributable (x64)
2 Likes

Not something I can try myself but I wonder if this type of approach might also work

parameter "GUIDS" = "{concatenation " " of (names of keys whose ((exists value "DisplayName" whose (it as string starts with "Microsoft Visual C++ " and it as string  contains "Redistributable ") of it) and (exists value "DisplayVersion" whose (it as string as version < "14") of it)) of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries))}"

wait cmd.exe /c "for %a in ({parameter "GUIDS"}) do msiexec.exe /qn /x%a"

Using a run action to echo the command to test the output of the msiexec command it looks correct

run cmd.exe /k "for %a in ({parameter "GUIDS"}) do echo msiexec.exe /qn /x%a"

1 Like

Thanks, that looks like something to try in the future if I run into other software that needs to be removed which has multiple versions/installs. Always better to have your approach that’s less hard-coded if I had the time to test it.

For now, I just needed it done since our vulnerability reports were getting hits. So it was listing all known versions and taking the easier approach. Once I got it to work for the VC++ 2008 redistributes, I threw in there the 2010-2013 since eventually they’d give us grief too.

1 Like