Getting registry information using Python
- by Willy
I am trying to pull registry info from many servers and put them all into one txt file. I got the code working fine in a .bat file. I hear that there is a way simpler way to do this in Python. I am intrigued and delighted to hear this. Can anyone help finish my code:
My working bat file:
echo rfsqlcl01app >> foo.txt
reg query "\\rfsqlcl01app\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\On Access Scanner\McShield\Configuration\Default" >> foo.txt
echo GLADGSQL01 >> foo.txt
reg query "\\GLADGSQL01\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\On Access Scanner\McShield\Configuration\Default" >> foo.txt
echo GLADGWEB01 >> foo.txt
reg query "\\GLADGWEB01\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\On Access Scanner\McShield\Configuration\Default" >> foo.txt
echo PAPERVISION >> foo.txt
My python code structure:
>>> server_list = open('server_test.txt', 'r')
>>> for line in server_list:
print r'reg query \\%s\blah\blah\blah' % line.strip()
reg query \\foo\blah\blah\blah
reg query \\moo\blah\blah\blah
reg query \\boo\blah\blah\blah
>>> server_list.close()