Updating registry in

In your script, you are using the New-Item Property cmdlet to attempt to update a registry key property value.When the registry key property exists, your script works. Here is a version of your script: $registry Path = "HKCU:\Software\Scripting Guys\Scripts" $Name = "Version" $value = "1" New-Item Property -Path $registry Path -Name $name -Value $value ` -Property Type DWORD -Force | Out-Null And here is the error message that appears when the registry key does not exist: You need to test for the existence of the registry key.This consists of three variables as shown here: $registry Path = "HKCU:\Software\Scripting Guys\Scripts" $Name = "Version" $value = "1" Now I can use the Test-Path cmdlet to see if the registry key exists. I need to put the Test-Path statement in a pair of parentheses so that I am "NOTing" the condition. (Test-Path $registry Path)) You may wonder why I cannot use Test-Path to verify that the registry key property does not exist.To do this, I use the If statement, and I look for the registry key that is NOT existing. After all, that is what the script is all about in the first place.Test = Setup Install From INFSection ( NULL, //Window to own any dialog boxes //created My Inf, //INF file containing the section My Section, //the section to install SPINST_ALL ^ SPINST_FILES,//which installation operations //to process NULL, //the relative root key NULL, //the source root path 0, //copy style NULL, //Message handler routine NULL, //Context NULL, //Device info set NULL //device info data ); is NULL because only file operations generate dialog boxes, and thus a parent window is not needed.

After the queue has successfully committed, you will need to update registry information for the product you are installing.

If you have such a need, you may want to check out this collection of Hey, Scripting Guy!

Blog posts, where I talk about structured error handling in Windows Power Shell scripts.

If the registry key does not exist, then you need to create the registry key, and then create the registry key property value.

The first thing I like to do is to create the path to the registry key, then specify the property name and the value I want to assign.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating registry in”

  1. This conversion enabled the 360 computer to monitor and control the entire production process the IRD engineers designed and built. This tightly secured area with limited access was required because of the sensitivity of the data that would ultimately be used to encode and emboss the credit and ID cards.