diff --git a/boot_up.py b/boot_up.py new file mode 100644 index 0000000..9defe29 --- /dev/null +++ b/boot_up.py @@ -0,0 +1,32 @@ +from sys import exit +from re import match +from subprocess import Popen + + +# Список выражений по которым проводится проверка +# По дефолту стоит регион R54, индекс 630300 +expr_list = [ + [r"^[a-zA-Z]+\d+$", "R54-630300"], # THE01 + [r"^\d+[a-zA-Z]+\d+$", "R54-"], # 630300THE01 + [r"^[rR]\d*[-]\d+[a-zA-Z]+\d+$", ""] # R54-630300THE01 +] + + +def main(): + comp_name = input("\nВведите имя ПК (пр. R54-630300THE01, Ctrl+C для выхода):\n> ") + for r in expr_list: + if match(r[0], comp_name): + comp_name = "{}{}".format(r[1], comp_name) + break + if match(expr_list[2][0], comp_name): + subprocess.Popen("powershell -ExecutionPolicy Unrestricted -Command \"Get-CimInstance -ClassName win32_operatingsystem -ComputerName "+comp_name+" | select csname, lastbootuptime\"").wait() + else: + print("Имя компьютера не распознано! Попробуйте еще раз.") + main() # Рекурсия наше все!... + + +if __name__ == '__main__': + try: + main() + except KeyboardInterrupt: + exit() diff --git a/boot_up.spec b/boot_up.spec new file mode 100644 index 0000000..9079c1d --- /dev/null +++ b/boot_up.spec @@ -0,0 +1,40 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['boot_up.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='boot_up', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=False, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None) diff --git a/boot_up_upx.spec b/boot_up_upx.spec new file mode 100644 index 0000000..9552729 --- /dev/null +++ b/boot_up_upx.spec @@ -0,0 +1,40 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['boot_up.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) + +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='boot_up_upx', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None) diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..6ef9be5 --- /dev/null +++ b/build.bat @@ -0,0 +1,3 @@ +@echo off +pyinstaller boot_up.spec +pyinstaller boot_up_upx.spec --upx-dir=upx\ \ No newline at end of file diff --git a/src_powershell/computer boot up time.ps1 b/src_powershell/computer boot up time.ps1 new file mode 100644 index 0000000..2df674f --- /dev/null +++ b/src_powershell/computer boot up time.ps1 @@ -0,0 +1,7 @@ + +write-host " (. R54-630300IT04):" +$pc_name = read-host + +Get-CimInstance -ClassName win32_operatingsystem -ComputerName $pc_name | select csname, lastbootuptime + +Pause