/build/static/layout/Breadcrumb_cap_w.png

PS for adding reg

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

Thanks


0 Comments   [ + ] Show comments

Answers (2)

Answer Summary:
Posted by: SMal.tmcc 7 years ago
Red Belt
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


Posted by: rileyz 7 years ago
Red Belt
0

Top Answer

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.'}

Comments:
  • Thank you!! It worked - shamu 7 years ago
 
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