Erstellen Sie eine Anwendung, um die installierte Anwendung mit Python zu durchsuchen
Voraussetzung - Tkinter in Python .
In diesem Artikel werden wir Python-Skripte schreiben, um nach einer installierten Anwendung unter Windows zu suchen und sie mit der GUI-Anwendung zu binden. Wir verwenden Winapps Module zum Verwalten installierter Anwendungen unter Windows.
Führen Sie diesen Befehl in Ihrem Terminal aus, um das Modul zu installieren:
pip install winapps
Methoden aus dem Winapps-Modul
Zum Drucken installierter Anwendungen verfügt das Modul winapps über die Methode winapps.list_installed() . T.
import
winapps
for
item
in
winapps.list_installed():
(item)
Ausgabe:
InstalledApplication (Name = 'Mi Smart Share', Version = '1.0.0.452', Installationsdatum = Keine, Installationsort = Keine, Installationsquelle = Keine, Änderungspfad = Keine, Herausgeber = 'Xiaomi Inc.', Deinstallationszeichenfolge = 'C: \\ Programm Dateien \\ MI \\ AIoT \\ MiShare \\ 1.0.0.452 \\ Uninstall.exe ')
InstalledApplication (name = 'Git version 2.27.0', version = '2.27.0', install_date = datetime.date (2020, 7, 22), install_location = WindowsPath ('D: / Installation_bulk / Git'), install_source = None , modify_path = None, publisher = 'Die Git-Entwicklungsgemeinschaft', uninstall_string = '' D: \\ Installation_bulk \\ Git \\ unins000.exe ”')
InstalledApplication (Name = 'Microsoft 365 - en-us', Version = '16 .0.13127.20408 ', Installationsdatum = Keine, Installationsort = WindowsPath (' C: / Programme / Microsoft Office '), Installationsquelle = Keine, Änderungspfad =' ”C. : \\ Programme \\ Gemeinsame Dateien \\ Microsoft Shared \\ ClickToRun \\ OfficeClickToRun.exe ”Szenario = Reparaturplattform = x64 Kultur = en-us ', Herausgeber =' Microsoft Corporation ', uninstall_string ='” C: \\ Programmdateien \\ Gemeinsame Dateien \\ Microsoft Shared \\ ClickToRun \\ OfficeClickToRun.exe ”Szenario = Installationsszenarien Subtyp = ARP Sourcetype = Keine productstoremove = O365HomePremRetail.16_en-us_x-keine Kultur = en-us Version.16 = 16.0 ′)
InstalledApplication (name = 'On Screen Display Utility', version = '1.0.0.140', install_date = None, install_location = None, install_source = None, modify_path = None, publisher = 'Xiaomi Inc.', uninstall_string = 'C: \\ Programmdateien \\ MI \\ OSD-Dienstprogramm \\ 1.0.0.140 \\ Uninstall.exe ')
InstalledApplication (Name = 'Intel (R) Management Engine-Komponenten', Version = '1921.14.0.1280', Installationsdatum = Keine, Installationsort = WindowsPath ('C: / Programme (x86) / Intel / Intel (R) Management Engine-Komponenten' ), install_source = None, modify_path = None, publisher = 'Intel Corporation', uninstall_string = '”C: \\ ProgramData \\ Intel \\ Paket-Cache \\ {1CEAC85D-2590-4760-800F-8DE5E91F3700} \\ Setup. exe ”-uninstall ')
………
Zum Durchsuchen der vorhandenen Anwendungen verfügt das Modul über die Methode search_installed ('App_name') .
for
item
in
winapps.search_installed(
'chrome'
):
(item)
Ausgabe:
InstalledApplication (name = 'Google Chrome', version = '85 .0.4183.102 ', install_date = datetime.date (2020, 9, 11),
install_location = WindowsPath (' C: / Programme (x86) / Google / Chrome / Application ') ), install_source = None,
modify_path = None, publisher = 'Google LLC', uninstall_string = '
' C: \\ Programme (x86) \\ Google \\ Chrome \\ Application \\ 85.0.4183.102 \\ Installer \\ Setup .exe ”
–uninstall –system-level –verbose-logging ')
Anwendung in Windows mit Tkinter suchen
from
tkinter
import
*
import
winapps
def
app():
for
item
in
winapps.search_installed(e.get()):
name.
set
(item.name)
version.
set
(item.version)
Install_date.
set
(item.install_date)
publisher.
set
(item.publisher)
uninstall_string.
set
(item.uninstall_string)
master
=
Tk()
master.configure(bg
=
'light grey'
)
name
=
StringVar()
version
=
StringVar()
Install_date
=
StringVar()
publisher
=
StringVar()
uninstall_string
=
StringVar()
Label(master, text
=
"Enter App name : "
,
bg
=
"light grey"
).grid(row
=
0
, sticky
=
W)
Label(master, text
=
"Name : "
,
bg
=
"light grey"
).grid(row
=
2
, sticky
=
W)
Label(master, text
=
"Version :"
,
bg
=
"light grey"
).grid(row
=
3
, sticky
=
W)
Label(master, text
=
"Install date :"
,
bg
=
"light grey"
).grid(row
=
4
, sticky
=
W)
Label(master, text
=
"publisher :"
,
bg
=
"light grey"
).grid(row
=
5
, sticky
=
W)
Label(master, text
=
"Uninstall string :"
,
bg
=
"light grey"
).grid(row
=
6
, sticky
=
W)
Label(master, text
=
"", textvariable
=
name,
bg
=
"light grey"
).grid(row
=
2
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
version,
bg
=
"light grey"
).grid(row
=
3
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
Install_date,
bg
=
"light grey"
).grid(row
=
4
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
publisher,
bg
=
"light grey"
).grid(row
=
5
, column
=
1
, sticky
=
W)
Label(master, text
=
"", textvariable
=
uninstall_string,
bg
=
"light grey"
).grid(row
=
6
, column
=
1
, sticky
=
W)
e
=
Entry(master, width
=
30
)
e.grid(row
=
0
, column
=
1
)
b
=
Button(master, text
=
"Show"
, command
=
app, bg
=
"Blue"
)
b.grid(row
=
0
, column
=
2
, columnspan
=
2
, rowspan
=
2
, padx
=
5
, pady
=
5
,)
mainloop()
Ausgabe: