Getting registry information using Python
Posted
by Willy
on Stack Overflow
See other posts from Stack Overflow
or by Willy
Published on 2010-03-11T11:56:14Z
Indexed on
2010/03/11
17:54 UTC
Read the original article
Hit count: 283
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()
© Stack Overflow or respective owner