Ask Your Question
4

How do you create an If statement to verify a registry value?

asked 2021-05-02 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-07-23 06:00:00 +0000

scrum gravatar image

Here is an example in PowerShell to verify a registry value:

if((Get-ItemProperty -Path 'HKLM:\Software\Company\Product' -Name 'Version').Version -eq '1.0.0.0') {
    Write-Host 'The registry value is correct.'
} else {
    Write-Host 'The registry value is incorrect.'
}

This code checks whether the Version value in the HKLM:\Software\Company\Product registry key is equal to "1.0.0.0". If it is, the If statement executes the true branch of the condition (outputs a message saying the registry value is correct). If not, the false branch executes (outputs a message saying the registry value is incorrect).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-02 11:00:00 +0000

Seen: 9 times

Last updated: Jul 23 '21