-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_me_first.bat
More file actions
104 lines (93 loc) · 3.36 KB
/
Copy pathrun_me_first.bat
File metadata and controls
104 lines (93 loc) · 3.36 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
@echo off
setlocal enabledelayedexpansion
REM ==========================================
REM Smart File Management System - One Click Setup & Run
REM ==========================================
REM Show welcome message
cls
color 0B
echo ==========================================
echo Smart File Management System - Auto Setup
echo ==========================================
echo.
echo This tool will automatically install everything required.
echo The user does not need to do anything manually.
echo.
pause
REM Check for .NET Desktop Runtime (required for running)
dotnet --list-runtimes | findstr /i "Microsoft.WindowsDesktop.App" >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo ✅ .NET Desktop Runtime already installed!
goto BUILD_APP
)
echo ❌ .NET Desktop Runtime not found. Installing automatically...
echo.
REM Try winget first
winget install Microsoft.DotNet.DesktopRuntime.8 --accept-source-agreements --accept-package-agreements --silent >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo ✅ .NET Desktop Runtime installed via winget!
timeout /t 5 /nobreak >nul
goto BUILD_APP
)
echo Winget failed. Trying direct download...
powershell -Command "& {
try {
$url = 'https://download.visualstudio.microsoft.com/download/pr/2e2e2e2e-2e2e-2e2e-2e2e-2e2e2e2e2e2e/2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e/dotnet-runtime-8.0.0-win-x64.exe'
Write-Host 'Downloading .NET Desktop Runtime...'
Invoke-WebRequest -Uri $url -OutFile 'dotnet-desktop-installer.exe' -UseBasicParsing
Write-Host 'Download completed!'
} catch {
Write-Host 'Download failed!'
exit 1
}
}"
if not exist "dotnet-desktop-installer.exe" (
echo ERROR: Could not download .NET Desktop Runtime
echo Please install manually from:
echo https://dotnet.microsoft.com/en-us/download/dotnet/8.0
pause
exit /b 1
)
echo Installing .NET Desktop Runtime silently...
start /wait dotnet-desktop-installer.exe /quiet /norestart
echo Verifying installation...
dotnet --list-runtimes | findstr /i "Microsoft.WindowsDesktop.App" >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo ✅ .NET Desktop Runtime installed successfully!
) else (
echo Installation may need a restart. Continuing anyway...
)
:BUILD_APP
echo.
echo [2/2] Publishing Smart File Management System Application...
cd /d "%~dp0"
dotnet restore --verbosity quiet
if %ERRORLEVEL% neq 0 (
echo Fixing NuGet...
dotnet nuget locals all --clear
dotnet restore
)
dotnet publish -c Release -r win-x64 --self-contained true --output publish >nul
if %ERRORLEVEL% equ 0 (
echo ✅ SUCCESS! Smart File Management System published successfully!
echo Copying application to main folder...
copy /Y "publish\FileOrganizer.exe" "FileOrganizerByKunal.exe" >nul
copy /Y "publish\appsettings.json" "appsettings.json" >nul
echo Launching application...
if exist "FileOrganizerByKunal.exe" (
start "" "FileOrganizerByKunal.exe"
echo.
echo You can now use Smart File Management System!
echo.
timeout /t 5
) else (
echo ERROR: FileOrganizerByKunal.exe not found in main folder!
echo Please check for build errors or run the EXE manually if present.
timeout /t 10
)
) else (
echo ❌ Publish failed. Try running as Administrator.
)
echo.
echo Setup complete!
pause