Untitled

 avatar
unknown
plain_text
a year ago
2.0 kB
0
Indexable
@echo off
SET "currentDir=%~dp0"

:: Check if running as administrator
net session >nul 2>&1
if %errorLevel% == 0 (
    echo Running as administrator.

	:: Delete existing folder before extracting, but keep Chrome and Edge
	echo Deleting existing files and folders except Chrome and Edge...
	for /D %%A in ("%currentDir%\yApp\*") do (
		if /I not "%%~nxA"=="Chrome" (
			if /I not "%%~nxA"=="Edge" (
				rmdir /s /q "%%~A"
			)
		)
	)
	for %%A in ("%currentDir%\yApp\*") do (
		if /I not "%%~nxA"=="Chrome" (
			if /I not "%%~nxA"=="Edge" (
				del /q "%%~A"
			)
		)
	)

    :: Create folder
    if not exist "%currentDir%\yApp" (
        echo Creating folder: yApp
        mkdir "%currentDir%\yApp"
    )

    :: Download file
    echo Downloading file...
    powershell -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.dropbox.com/scl/fi/gorzw31xn78no2ian5t7m/yApp.zip?rlkey=am7gzdsd338t80fqf45xmcy9e&dl=1', '%currentDir%\yApp\data.zip') }"

    :: Extract file
    echo Extracting file...
    powershell -Command "& { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('%currentDir%\yApp\data.zip', '%currentDir%\yApp') }"

    :: Delete ZIP file
    echo Deleting ZIP file...
    del /Q /F "%currentDir%\yApp\data.zip"

    :: Run run.bat
    echo Running run.bat...
    cd /D "%currentDir%\yApp"
    call run.bat

	echo Creating a shortcut...
	powershell -Command "& { $WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%currentDir%\run.lnk'); $Shortcut.TargetPath = '%currentDir%\yApp\run.bat'; $Shortcut.Save() }"
	exit /B
) else (
    echo Not running as administrator. Restarting with admin rights.
    powershell -Command "& { Start-Process cmd.exe '/c %~f0' -Verb RunAs }"
    exit /B
)
exit
Leave a Comment