Reputation: 75
I need to identify if dot.net 4.5 is installed and if it isn't then install it. I can't check to see if the directory is present as it uses the same one as 4.0. I have found that if I put the following in a .bat file it displays the version.
wmic /namespace:\root\cimv2 path win32_product where "name like '%%.NET%%'" get version
but I need to do this in some sort of if statement so that I can then run the exe if it is false.
Can anyone help please?
Upvotes: 2
Views: 4672
Reputation: 743
Bet you it doesn't display the version. This does
wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version
Look before the root word.
Then use the Findstr command errorlevel to decide what to do.
(wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version|findstr /c:"4.5"
If not errorlevel 1 echo sucess&goto :eof)
Added space before the get (my space key is faulty).
Upvotes: 2
Reputation: 11191
I found this MSDN article.
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP" /s|FIND " Version"|FIND "4.5."||ECHO Not found! Start setup!
This command will check registry sub keys for "Version" "4.5". You can replace ECHO ...
with install command, or GOTO
in a batch for further processing..
Upvotes: 2