Created
July 20, 2020 11:42
-
-
Save 0x2a94b5/3b265d74c07abe2708e676a5dad2ed63 to your computer and use it in GitHub Desktop.
get hostname on windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# get local computer name on windows | |
# package: pyinstaller -y -F -c getHostname.py | |
# | |
from subprocess import run, PIPE | |
cmd = "C:\\Windows\\System32\\HOSTNAME.EXE" | |
process = run(cmd, shell=True, stdout=PIPE, universal_newlines=True) | |
hostname = process.stdout.strip() | |
print("hostname is %s" % hostname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment