Seite 1 von 1

Schokoladeninstallation?

Veröffentlicht: 1. August 2018 - 1:29 Uhr
von Empbilly
Hallo,

Wie kann ich einen Code erstellen, der den folgenden Befehl ausführt?

Code: Alle auswählen

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Betreff: Chocolatey-Installation?

Veröffentlicht: 1. August 2018 - 12:20 Uhr
von agauvrit
Eine bessere Methode wäre es, die Datei install.ps1 herunterzuladen und lokal auszuführen, anstatt sie jedes Mal herunterzuladen

Code: Alle auswählen

run(r"%systemroot%\System32\WindowsPowerShell\v1.0\powershell -NoProfile -ExecutionPolicy Bypass -Command ./install.ps1")

Betreff: Chocolatey-Installation?

Veröffentlicht: 2. August 2018 - 16:19 Uhr
von Empbilly
Danke @agauvrit!! :)

Code: Alle auswählen

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    print("Instalando Chocolatey...")
    try:
        filecopyto('install.ps1','c:\\')
        run(r"%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command c:\install.ps1; SET 'PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin'")
    except (RuntimeError, TypeError, NameError):
        print("Erro na instalação do Chocolatey")
    print("Chocolatey instalado com sucesso!")

def uninstall():
    print("Desinstalando o Chocolatey...")
    try:
        remove_tree(ur'%allusersprofile%\chocolatey')
    except (RuntimeError, TypeError, NameError):
        print("Erro na desinstalação do Chocolatey")
    print("Chocolatey desinstalado com sucesso!")
Ist die Deinstallationsfunktion korrekt? Kann ich die Umgebungsvariable %allusersprofile% auf diesem Weg übergeben?