Scripting Question

PS for adding reg

06/08/2016 656 views

Can anyone tell methe script to look for a file and if present add a registry.


Answer Summary:
0 Comments   [ + ] Show comments


Answer Chosen by the Author

Try something like this, checking for the file is easy, writing the registry key is the pain in the ass bit unless you are using powershell 5, or you can take the easy way out and call reg.exe to write the key.

If ((Test-Path C:\TheFileYou\AreLookingFor.txt) -eq $true)
        {Write-Debug 'Write your registy key in this block'}
    Else{Write-Debug 'File not found.'}
Answered 06/09/2016 by: rileyz
Red Belt

  • Thank you!! It worked

All Answers

if it is windows powershell scripting you can use a "IF Exists then or else command"


Answered 06/08/2016 by: SMal.tmcc
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ