Nov-21-2023, 09:43 PM
Quote:I have the small code here, as it stands right now it works perfectly
What I'm trying to do is to get it to stop looking at program = r'\ccsetup551.exe'
I'm trying to get it to look in
with open(r'Program_Recovery2_Selection.txt', 'r') as file:
file4 = file.read().replace('\n', "")
file.close()
for the file name but every time I replace program with file4
it tells me it's unknown
except is only if the file does not have a description
it will display an unknown
As you can see I am using ccleaner.exe as an example
so how do I get this script to look in the Program_Recovery2_Selection.txt
and add it to the path
import win32api file4 = '' def get_file_description(windows_exe): global file4 try: language, codepage = win32api.GetFileVersionInfo(windows_exe, '\\VarFileInfo\\Translation')[0] stringfileinfo = u'\\StringFileInfo\\%04X%04X\\%s' % (language, codepage, "FileDescription") description = win32api.GetFileVersionInfo(windows_exe, stringfileinfo) with open(r'Program_Recovery2_Selection.txt', 'r') as file: <----- look in here file4 = file.read().replace('\n', "") file.close() except (Exception,): # adding (Exception,) seem to work I don't know why description = "unknown" # if the program doesn't have a description return description path = r'\\MyCloudPR4100\Programs\Specialty tools' program = r'\ccsetup551.exe' # ccsetup551.exe <--- not here print(get_file_description(path + program))