MSI的PackageCode是否存储在Windows中的任何位置?

时间:2015-11-05 14:04:40

标签: .net windows-installer

我可以从ProductCode和其他注册表项中获取\Uninstall,但我没有看到特定的PackageCode列表。

有没有办法可靠地获取已安装的MSI的包裹代码列表?打开每个MSI不是首选,但仅出于性能原因。

3 个答案:

答案 0 :(得分:1)

请在下面找到一个VBScript,以检索各种MSI信息,包括程序包代码。

在桌面上创建VBScript文件,然后粘贴以下代码。从桌面运行脚本,然后查找创建的文件 import os from datetime import datetime import pandas as pd import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email import encoders files = [] drop_path = 'C:\\Data Drop\\' path = os.chdir(drop_path) datestamp = datetime.now().strftime(' (%m-%d-%Y)') #Make a CSV copy of each file for c in os.listdir(path): file_name, file_ext = os.path.splitext(c) xlsx = pd.read_excel(file_name+file_ext) xlsx.to_csv(file_name+'.csv', encoding='utf-8') files.append(file_name+'.csv') print('CSV copies created\n') #Send to appropriate email addresses recipient = '' for s in files: print('Sending ',s) if s == 'file1.csv': recipient = '<email1@gmail.com>' elif s == 'file2.csv': recipient = '<email2@gmail.com>' email_user = 'sender@gmail.com' email_password = 'password' email_send = recipient msg = MIMEMultipart() msg['From'] = email_user msg['To'] = email_send msg['Subject'] = "Data transmittal" body = 'Data transmittal attached' msg.attach(MIMEText(body,'plain')) attached_file = s attachment = open(attached_file,'rb') part = MIMEBase('application','octet-stream') part.set_payload((attachment).read()) encoders.encode_base64(part) part.add_header('Content-Disposition',"attachment; filename= "+attached_file) msg.attach(part) text = msg.as_string() server = smtplib.SMTP('smtp.gmail.com',587) server.starttls() server.login(email_user,email_password) server.sendmail(email_user,email_send,text) print(s,'sent.\n') server.quit() print('All data has been sent.\n') #Remove CSV files once sent. for files in os.listdir(drop_path): if files.endswith('.csv'): os.remove(drop_path + files) print('CSV files cleared.\n') #Add the date to the end of each xlsx file name for f in os.listdir(path): file_name, file_ext = os.path.splitext(f) if file_ext==".csv": continue else: new_name = file_name+datestamp+file_ext os.rename(f, new_name) print('Dates added to file names.\n') print('\nAll operations are complete.') 。在Excel或同等版本中打开此文件,然后导入逗号分隔的文件以进行正确查看。

msiinfo.csv

答案 1 :(得分:0)

包裹代码实际上仅用于MSI,因此MSI不会暴露很多关于它们的信息。产品代码已经唯一标识已安装的产品,因此在给定产品代码的情况下,您可以使用MsiGetProductInfoExINSTALLPROPERTY_PACKAGECODE来获取产品的包裹代码。

答案 2 :(得分:0)

您可以在 HKEY_CLASSES_ROOT \ Installer \ Products {PRODUCT_CODE_IN_COMPRESSED_GUID_FORMAT} 中找到一个 PackageCode 值。

请注意,PackageCode字符串值也将采用压缩GUID格式(无破折号和“反向”的GUID),因此,如果将该值与MSI文件中的值进行比较(例如,使用SuperOrca)由于显示格式的原因,它们可能不匹配。