2014年6月24日 星期二

Find registry address of NIC by command line

Command:
reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318} /s /f "Intel(R) 82579LM Gigabit Network Connection"

Filter:
reg query HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318} /s /f "Intel(R) 82579LM Gigabit Network Connection" | find "{4D36E972-E325-11CE-BFC1-08002BE10318}" > NICaddr.txt

reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318} /s /c /e /f "Intel(R) 82579LM Gigabit Network Connection" | find "HKEY_LOCAL_MACHINE" > NICRegAddr.txt

2014年6月7日 星期六

How do I get the path of the current executed file in python?





Reference:
http://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python



Following are for copy&paste:
#
some_path/module_locator.py:
def we_are_frozen():
    # All of the modules are built-in to the interpreter, e.g., by py2exe
    return hasattr(sys, "frozen")

def module_path():
    encoding = sys.getfilesystemencoding()
    if we_are_frozen():
        return os.path.dirname(unicode(sys.executable, encoding))
    return os.path.dirname(unicode(__file__, encoding))
some_path/main.py:
import module_locator
my_path = module_locator.module_path()