Contactez nous

Chocolatey installation?

Share here your tips or issues concerning WAPT Console or WAPT Agent / Venez ici partager vos problèmes et astuces concernants la console et l'agent WAPT
Règles du forum

* Questions can be asked in English or in French. If the thread is started in English, stick to English, if it is started in French, stick to French.
* Vous pouvez poser vos questions en Français ou en Anglais. Si un sujet est commencé en français, merci de répondre en français. Si un sujet est commencé en anglais, merci de répondre en anglais.

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"
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")
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?