This uses the inbuilt compilers in Windows 10 - there are three VB.NET compilers and three C# compilers - just copy each text file into the same folder and double click the batch file to make the program.
@Echo Off
ECHO Three files follow
ECHO PreventSleep.bat
ECHO.
ECHO This file compiles KeepDisplayOn.vb and KeepSystemOn.vb to KeepDisplayOn.exe and KeepSystemOn.exe using the system VB.NET compiler.
ECHO.
ECHO Runs a program preventing sleeping or the display turning off while the program runs
ECHO.
ECHO To Use
ECHO KeepDisplayOn "C:\windows\notepad"
ECHO KeepSystemOn "C:\windows\notepad"
ECHO.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\KeepDisplayOn.vb" /out:"%~dp0\KeepDisplayOn.exe" /target:winexe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\KeepSystemOn.vb" /out:"%~dp0\KeepSystemOn.exe" /target:winexe
pause
'KeepSystemOn.vb
imports System.Runtime.InteropServices
Public Module MyApplication
Public Declare UNICODE Function SetThreadExecutionState Lib "Kernel32" (ByVal esFlags as Integer) as Integer
Public Const ES_AWAYMODE_REQUIRED = &h40
Public Const ES_CONTINUOUS = &h80000000
Public Const ES_DISPLAY_REQUIRED = &h2
Public Const ES_SYSTEM_REQUIRED = &h1
Public Const ES_USER_PRESENT = &h4
Public Sub Main ()
Dim wshshell as Object
Dim Ret as Integer
WshShell = CreateObject("WScript.Shell")
Ret = SetThreadExecutionState(ES_Continuous + ES_System_Required + ES_Awaymode_Required)
WshShell.Run(Command(), , True)
End Sub
End Module
'KeepDisplayOn.vb
imports System.Runtime.InteropServices
Public Module MyApplication
Public Declare UNICODE Function SetThreadExecutionState Lib "Kernel32" (ByVal esFlags as Integer) as Integer
Public Const ES_AWAYMODE_REQUIRED = &h40
Public Const ES_CONTINUOUS = &h80000000
Public Const ES_DISPLAY_REQUIRED = &h2
Public Const ES_SYSTEM_REQUIRED = &h1
Public Const ES_USER_PRESENT = &h4
Public Sub Main ()
Dim wshshell as Object
Dim Ret as Integer
WshShell = CreateObject("WScript.Shell")
Ret = SetThreadExecutionState(ES_Continuous + ES_Display_Required + ES_Awaymode_Required)
WshShell.Run(Command(), , True)
End Sub
End Module