Registry Query and Use Output in Post-Deploy Script?
...using Windows 7...
I have a sqlserver.exe.config file that needs开发者_JAVA技巧 to get copied to the SQL Server BINN directory on my local machine (for the SQLExpress instance).
I can't assume the location, so I poked around in the registry and found
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\Setup "sqlpath"
So in a CMD I would like to get the value of that and then copy the file to that place. The reason I need to do it in CMD is because this should be in a post-build event. Can anyone recommend how to do this with REG or anything else?
Thanks.
You've got many solutions.
1. You want to work in th old CMD fashion
You can use REG.EXE command line program :
C:\silogix>reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fax" /v ArchiveFolder
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fax
ArchiveFolder REG_SZ C:\ProgramData\Microsoft\Windows NT\MSFax
Y'll fin in an other article how to split the response.
2. With Powershell
In PowerShell command line (or script) you can access the registry like a drive :
PS C:\silogix> (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Fax").ArchiveFolder
C:\ProgramData\Microsoft\Windows NT\MSFax
It's shorter to write. Registry keys are items and values are properties. PowerShell is a powerfull command line interpreter (you can use for scripting) which is on the top of .NET Framework. It makes scripting easy for C# programmers.
JP
精彩评论