Skip to content

Commit 7ea6cd2

Browse files
authored
Correcao da instalação do chocolatey
1 parent 0ccdb52 commit 7ea6cd2

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

functions.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import requests
33
import os
44
import logging
5+
import urllib.request
56
from config import Config
67

78

@@ -52,24 +53,14 @@ def addtodomain(self, dominio, usuario, senha):
5253

5354
# Executa instalacao de programas
5455
def installprograma(self, diretorioarcom, programa):
55-
comando_cmd_script = '''
56-
@echo off
57-
58-
SET DIR=%~dp0%
59-
60-
::download install.ps1
61-
%systemroot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "((new-object net.webclient).DownloadFile('https://community.chocolatey.org/install.ps1','%DIR%install.ps1'))"
62-
::run installer
63-
%systemroot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"
64-
'''
65-
cmd_script_name = 'install_chocolatey.bat'
66-
cmd_script_path = diretorioarcom + '\\' + cmd_script_name
6756
if not os.path.isfile(self.chocolateypath):
57+
script_url = 'https://community.chocolatey.org/install.ps1'
58+
ps_script_name = 'install_chocolatey.ps1'
59+
ps_script_path = diretorioarcom + '\\' + ps_script_name
6860
self.reportar("Executando instalação do chocolatey")
69-
with open(cmd_script_path, 'w') as file:
70-
file.write(comando_cmd_script)
61+
urllib.request.urlretrieve(script_url, ps_script_path)
7162
self.executar(
72-
cmd_script_path
63+
'Powershell.exe -File ' + ps_script_path
7364
)
7465
self.executar(
7566
self.chocolateypath + " config set cacheLocation " + diretorioarcom

0 commit comments

Comments
 (0)