procedure CloseSleepAndDisplayOn; begin ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /monitor-timeout-ac 0', nil, SW_HIDE); ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /monitor-timeout-dc 0', nil, SW_HIDE); ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /hibernate-timeout-ac 0', nil, SW_HIDE); ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /hibernate-timeout-dc 0', nil, SW_HIDE); ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /standby-timeout-ac 0', nil, SW_HIDE); ShellExecute(0, 'open', 'cmd.exe', '/c powercfg /x /standby-timeout-dc 0', nil, SW_HIDE); end; procedure EnableWindowsFirewall(turnOn: Boolean); const firewall_cmd: array[Boolean] of string = ('/c netsh advfirewall set allprofiles state off', '/c netsh advfirewall set allprofiles state on'); begin ShellExecute(0, 'open', 'cmd.exe', PChar(firewall_cmd[turnOn]), nil, SW_HIDE); end; procedure OpenRemoteDesktop; var Reg: TRegistry; v: Integer; sText: string; begin Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; if not Reg.OpenKey('SYSTEM\ControlSet001\Control\Terminal Server', True) then Exit; Reg.WriteInteger('fDenyTSConnections', 0); Reg.CloseKey; Reg.Free; Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; if not Reg.OpenKey('SYSTEM\ControlSet001\Services\SharedAccess\Epoch', True) then Exit; v := Reg.ReadInteger('Epoch'); Reg.WriteInteger('Epoch', v + 3); Reg.CloseKey; Reg.Free; Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; if not Reg.OpenKey('SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules', True) then Exit; sText := Reg.ReadString('RemoteDesktop-Shadow-In-TCP'); StringReplace(sText, 'Active=FALSE', 'Active=TRUE', []); Reg.WriteString('RemoteDesktop-Shadow-In-TCP', sText); sText := Reg.ReadString('RemoteDesktop-UserMode-In-TCP'); StringReplace(sText, 'Active=FALSE', 'Active=TRUE', []); Reg.WriteString('RemoteDesktop-UserMode-In-TCP', sText); sText := Reg.ReadString('RemoteDesktop-UserMode-In-UDP'); StringReplace(sText, 'Active=FALSE', 'Active=TRUE', []); Reg.WriteString('RemoteDesktop-UserMode-In-UDP', sText); Reg.CloseKey; Reg.Free; SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0); end;