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

Thanks

Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answer Chosen by the Author

0
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
Please log in to comment

Answers

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

https://www.google.com/search?q=if+exist+then&ie=utf-8&oe=utf-8#q=if+exist+then+windows+powershell


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

Please log in to comment
Answer this question or Comment on this question for clarity