-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowsF.py
More file actions
146 lines (125 loc) · 4.77 KB
/
windowsF.py
File metadata and controls
146 lines (125 loc) · 4.77 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
import subprocess
import urllib.request
from auxFun import cleanOldFiles, getPath
import wget
from installThings import checkInstalled
# Função auxiliar para rodar comandos silenciosos
def enableDISMFeature(feature_name, display_name):
print(f"Processing: {display_name}...", end=' ')
command = [
"dism", "/online", "/enable-feature",
f"/featurename:{feature_name}",
"/all", "/NoRestart"
]
try:
result = subprocess.run(
command,
check=False,
capture_output=True,
text=True
)
# Código 0 = Sucesso
# Código 3010 = Sucesso (Reinicialização Pendente)
if result.returncode == 0:
print("Done.")
return True
elif result.returncode == 3010:
print("Done (Restart required).")
return True
else:
# Se deu erro real (ex: falta de admin), mostramos o motivo
print("ERRO.")
print(f" Log: {result.stderr.strip()}")
# Dica extra: Se o erro for 740, é falta de Admin
if "740" in str(result.returncode) or "elevation" in result.stderr.lower():
print(" -> Tip: Try running with admin.")
return False
except FileNotFoundError:
print("DISM not found (windows corrupted)")
return False
def run_silent_installer(installerPath, args):
try:
# Monta o comando: "programa.exe /quiet /norestart"
command = [installerPath] + args
subprocess.run(command, check=True)
return True
except subprocess.CalledProcessError:
return False
except Exception as e:
print(f"Erro: {e}")
return False
def install35():
print("Trying to activate .NET 3.5, could take a few minutes")
command = [
"dism",
"/online",
"/enable-feature",
"/featurename:NetFX3",
"/all",
"/NoRestart"
]
try:
subprocess.run(command, check=True)
print("NET 3.5 activated!")
except subprocess.CalledProcessError:
print("Error on .NET 3.5 activation (can be windows update issue).")
def installDix():
currentFolder = getPath()
cleanOldFiles(currentFolder, '*dxwebsetup*.exe')
print("downloading and installing -> DirectX End-User Runtime...")
url = "https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe"
dest = os.path.join(os.environ['USERPROFILE'], 'MaleniaPF', 'Downloads', 'dxwebsetup.exe')
try:
urllib.request.urlretrieve(url, dest)
except Exception as e:
print(f"Error with the download: {e}")
return
print("Installing DirectX...")
if run_silent_installer(dest, ["/Q"]):
print("DirectX Updated/Installed")
else:
print("Error on the installation")
# Credits for the file: https://github.com/abbodi1406/vcredist
#Man, youre 'abbodi1406' THE GOAT.
def installVCREDIST():
print("searching VCredist AIO (abbodi1406)...")
currentFolder = getPath()
cleanOldFiles(currentFolder, '*VisualCppRedist*.exe')
cleanOldFiles(currentFolder, '*AIO*.exe')
downloadPath = os.path.join(os.environ['USERPROFILE'], 'MaleniaPF', 'Downloads')
try:
pathh = wget.download('https://kutt.it/vcpp', downloadPath)
if os.path.exists(pathh):
print('\nDownload was a sucess!')
else:
print('Download failed.')
except Exception as e:
print(f"No webserver for the download: {e}")
def installModernDotNet():
print("Installing .NET Desktop Runtimes via Winget...")
runtimes = ["Microsoft.DotNet.DesktopRuntime.6", "Microsoft.DotNet.DesktopRuntime.8", "Microsoft.DotNet.Runtime.5", "Microsoft.DotNet.Runtime.7", "Microsoft.DotNet.Runtime.10", "Microsoft.DotNet.Runtime.9"]
for rt in runtimes:
if checkInstalled(rt) == False:
subprocess.run(["winget", "install", "-e", "--id", rt, "--silent", "--accept-package-agreements", "--accept-source-agreements"])
else:
print(f'{rt} already installed.')
def powerUlt():
print("\nUltimate performance power mode...")
cmd = ["powercfg", "-duplicatescheme", "e9a42b02-d5df-448d-aa00-03f14749eb61"]
try:
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL)
print("Done.\nCheck control panel")
except:
print("Error, try again.")
def wslComponents():
print("\n[DEV PACK] preparing vt...")
enableDISMFeature("Microsoft-Windows-Subsystem-Linux", "(WSL)")
enableDISMFeature("VirtualMachinePlatform", "VT platform")
def legacyGaming():
enableDISMFeature("DirectPlay", "DirectPlay (Legacy Games)")
def featuresMain():
install35()
installDix()
installModernDotNet()
installVCREDIST()