-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfigure_env.bat
37 lines (33 loc) · 1.59 KB
/
configure_env.bat
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
@echo off
echo =================================================================
echo :: More information: https://github.com/licyk/sd-webui-all-in-one
echo =================================================================
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo :: Requesting administrative privileges
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo :: Write vbs script to request administrative privileges
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo :: Executing vbs script
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
echo :: Launch CMD with administrative privileges
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
goto configureEnv
:configureEnv
title Configure environment
echo :: Set PowerShell execution policies
echo :: Executing command: "Set-ExecutionPolicy Unrestricted -Scope CurrentUser"
powershell "Set-ExecutionPolicy Unrestricted -Scope CurrentUser"
echo :: Enable long paths supported
echo :: Executing command: "New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 -PropertyType DWORD -Force"
powershell "New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 -PropertyType DWORD -Force"
echo :: Configure completed
echo :: Exit environment configuration script
pause