Home > OS >  Where there is a problem to open a remote terminal failure?
Where there is a problem to open a remote terminal failure?

Time:09-29

 
# include & lt; Windows. H>
#include
#include

Void CreateStringReg (hkeys hRoot, char * szSubKey, char * ValueName, char * Data) {
Hkeys hkeys;
Long lRet=RegCreateKeyEx (hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, & amp; Hkeys, NULL);
If (lRet! ERROR_SUCCESS)={
Printf (" error no aRegCreateKeyEx % s \ n ", szSubKey);
return ;
}
LRet=RegSetValueEx (hkeys, ValueName, 0, REG_SZ, (BYTE *) Data, strlen (Data));
If (lRet! ERROR_SUCCESS)={
Printf (" error no aRegCreateKeyEx % s \ n ", ValueName);
return ;
}
RegCloseKey (hkeys);
}

Void CreateDWORDReg (hkeys hRoot, char * szSubKey, char * ValueName, DWORD Data) {
Hkeys hkeys;
Long lRet=RegCreateKeyEx (hRoot, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, & amp; Hkeys, NULL);
If (lRet! ERROR_SUCCESS)={
Printf (" error no aRegCreateKeyEx % s \ n ", szSubKey);
return ;
}
DWORD dwSize=sizeof (DWORD);
LRet=RegSetValueEx (hkeys, ValueName, 0, REG_SZ, (BYTE *) & amp; The Data, dwSize);
If (lRet! ERROR_SUCCESS)={
Printf (" error no aRegCreateKeyEx % s \ n ", ValueName);
return ;
}
RegCloseKey (hkeys);
}

Void Reboot () {
HANDLE hToken;
The TOKEN_PRIVILEGES TKP;
if(! OpenProcessToken (GetCurrentProcess (), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, & amp; HToken)) return;
LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, & amp; TKP. Privileges [0]. Luid);
TKP. PrivilegeCount=1;
TKP. Privileges [0]. Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges (hToken, FALSE, & amp; TKP, 0, (PTOKEN_PRIVILEGES), NULL, 0);
ExitWindowsEx (EWX_REBOOT | EWX_FORCE, 0);
}

Int main (int arg c, char * * argv) {
DWORD Port=atoi (argv [1]).
CreateStringReg (HKEY_LOCAL_MACHINE, "SOFTWARE \ \ Policies \ \ Microsoft \ \ Windows \ \ CurrentVersion \ \ netcache", "Enabled" and "0");
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SOFTWARE \ \ Policies \ \ Microsoft \ \ Windows \ \ Installer", "EnableAdminTSRemote", 0 x00000001);
CreateStringReg (HKEY_LOCAL_MACHINE, "SOFTWARE \ \ Policies \ \ Microsoft \ \ Windows NT \ \ CurrentVersion \ \ Winlogon", "ShutdownWithoutLogon", "0");
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server" and "TSEnabled", 0 x00000001);
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Services \ \ TermDD", "Start", 0 x00000002);
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Services \ \ TermService", "Start", 0 x00000002);
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server" and "fDenyTSConnections", 0 x00000001);
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server \ \ RDPTcp", "PortNumber", the Port).
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server \ \ WinStations \ \ RDP - Tcp", "PortNumber", the Port).
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server \ \ Wds \ \ RDPWD \ \ Tds \ \ TCP", "PortNumber", the Port).
CreateStringReg (HKEY_USERS, ". The DEFAULT \ \ the rid_device_info_keyboard Layout \ \ Toggle ", "HotKey", "2");
CreateDWORDReg (HKEY_LOCAL_MACHINE, "SYSTEM \ \ CurrentControlSet \ \ Control \ \ Termianl Server" and "fDenyTSConnections", 0 x00000000);
OSVERSIONINFO osver={sizeof (OSVERSIONINFO)};
GetVersionEx (& amp; Osver);
If (osver. DwMajorVersion==5 & amp; & Osver. DwMinorVersion==0) {
Reboot ();
}
return 0;
}


CodePudding user response:

Just change the registry? Permissions have?

CodePudding user response:

reference 1st floor ojc8882003 response:
just changed the registry? Permissions have?
what permissions? Is looking at a book of self-study, not sure
  • Related