top of page

Run Latest File Program

import os import re import time def run_program(program): try: dir_path, base_name = os.path.split(program) base_name += ' ' max_version = [] max_version_file = None for file_name in os.listdir(dir_path): if file_name.startswith(base_name) and file_name.endswith('.exe'): match = re.search(r'(\d+(?:\.\d+)*)\.exe$', file_name) if match: version_str = match.group(1) version_num = list(map(int, version_str.split('.'))) if max_version == [] or version_num > max_version: max_version = version_num max_version_file = file_name if max_version_file is not None: # Here you can run your program print(max_version_file) os.startfile(os.path.join(dir_path, max_version_file)) else: print(f"No version of the program found in {dir_path}") time.sleep(10) except Exception as e: print(f'Failed {e}') time.sleep(10) run_program('A:\\program')

4 views0 comments

Recent Posts

See All

Table Data to String Array

for row in range(self.table.rowCount()): for column in range(self.table.columnCount()): DATA = DATA + (self.table.item(row,column).text()) + "+" DATA = DATA[:-1

Self Signing Cert Creator

import os from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLineEdit, QLabel from OpenSSL import crypto, SSL class SSLGenerator(QWidget): def __init__(self): s

bottom of page