如果我运行下面的代码,我很确定我应该获得该应用程序的产品名称和GUID(例如App Path | {xxx})。但是我只是得到路径而没有显示GUID。有人可以帮我吗?
import time
class_stats = {
"Warrior": (50, 7, 95),
"Hunter" : (40, 10, 85),
"Wizard" : (35, 12, 80),
}
class ClassBase:
def __init__(self, class_name, health, damage, hit_chance):
self.class_name = class_name
self.health = health
self.damage = damage
self.hit_chance = hit_chance
def get_choice(question, choices):
print(question)
letter_choice_dict = {}
for i, choice in enumerate(choices):
letter_choice_dict[chr(ord("A") + i)] = choice
for letter, choice in letter_choice_dict.items():
print(letter + ") " + choice)
user_choice = input().upper()
try:
return letter_choice_dict[user_choice]
except KeyError:
raise ValueError("Invalid choice " + user_choice)
def main():
print("Welcome to Blades of Goblonia!")
user_name = input("What is your name?")
print("Hello, " + user_name + "!")
chosen_class = get_choice("What class would you like to be?", class_stats.keys())
stats = class_stats[chosen_class]
user = ClassBase(chosen_class, *stats)
print("You are a " + user.class_name + "!")
enemy = ClassBase("Goblin", 30, 10, 60)
print("Out of nowhere, a", enemy.class_name, "appears!")
time.sleep(1)
action_chosen = get_choice("Would you like to", ["Hit", "Run", "Heal"])
# do something with user and/or enemy depending on action_chosen
if __name__ == "__main__":
main()
答案 0 :(得分:1)
我相信UninstallString
值是通过Add/Remove Programs
卸载应用程序时执行的值。如控制台输出所示,它是可执行文件的路径。
您检索产品ID的方式...
string prdctId = uninstlString.Substring(12);
...因此不正确,因为您正在采用部分路径。您需要传递给MsiExec.exe /x
的是产品代码,它是注册表项名称本身,即...
string prdctId = keyName;
如果您要从Command Prompt
调用该命令行,我很确定大括号将需要在产品代码两边加上引号。我不确定直接调用可执行文件时是否需要这样做,但这不会造成伤害...
uninstallProcess.StartInfo.Arguments = " /x \"" + prdctId + "\" /quiet /norestart";