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:
Please log in to answer
Posted by:
SMal.tmcc
8 years ago
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
https://www.google.com/search?q=if+exist+then&ie=utf-8&oe=utf-8#q=if+exist+then+windows+powershell
Posted by:
rileyz
8 years ago
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 8 years ago