-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall.bat
More file actions
60 lines (51 loc) · 1.85 KB
/
Copy pathInstall.bat
File metadata and controls
60 lines (51 loc) · 1.85 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
@echo off
setlocal
echo ==============================================
echo AudioKeepAwake Installer
echo ==============================================
:: Find the C# Compiler dynamically
set CSC=
for /f "delims=" %%d in ('dir /b /ad /o-n "%WINDIR%\Microsoft.NET\Framework64\v*" 2^>nul') do (
if exist "%WINDIR%\Microsoft.NET\Framework64\%%d\csc.exe" (
set "CSC=%WINDIR%\Microsoft.NET\Framework64\%%d\csc.exe"
goto :found_csc
)
)
for /f "delims=" %%d in ('dir /b /ad /o-n "%WINDIR%\Microsoft.NET\Framework\v*" 2^>nul') do (
if exist "%WINDIR%\Microsoft.NET\Framework\%%d\csc.exe" (
set "CSC=%WINDIR%\Microsoft.NET\Framework\%%d\csc.exe"
goto :found_csc
)
)
:found_csc
if not defined CSC (
echo [ERROR] C# compiler not found. Make sure Windows .NET Framework is installed.
pause
exit /b
)
echo Using compiler: "%CSC%"
:: Compile the app
echo Compiling AudioKeepAwake.cs into a background application...
"%CSC%" /nologo /t:winexe /out:"AudioKeepAwake.exe" /r:System.Windows.Forms.dll /r:System.Drawing.dll "AudioKeepAwake.cs"
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Compilation failed!
pause
exit /b
)
echo [SUCCESS] Compilation complete: AudioKeepAwake.exe generated.
:: Move to Startup Folder
set STARTUP_DIR="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup"
echo Installing to %STARTUP_DIR%...
copy /Y "AudioKeepAwake.exe" %STARTUP_DIR% >nul
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Could not install to Startup folder.
pause
exit /b
)
echo [SUCCESS] Installed! It will run automatically when you turn on your PC.
:: Start it right now
echo Starting AudioKeepAwake in the background...
start "" %STARTUP_DIR%\AudioKeepAwake.exe
echo.
echo All done! You can now close this window safely. The app is running silently in the background.
pause