Page 1 sur 1

Chocolatey installation?

Publié : 01 août 2018 - 01:29
par empbilly
hello,

How I can make a code that execute the below command?

Code : Tout sélectionner

@"%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"

Re: Chocolatey installation?

Publié : 01 août 2018 - 12:20
par agauvrit
A better way would be to download install.ps1 file and execute it locally instead of downloading it every time

Code : Tout sélectionner

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

Re: Chocolatey installation?

Publié : 02 août 2018 - 16:19
par empbilly
Thanks @agauvrit!! :)

Code : Tout sélectionner

# -*- 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!")
The uninstall function is correct? I can pass the %allusersprofile% environment variable that way?