...and using system() instead of REG apis is horrible.
It will behoove you to learn the Windows API's if you plan on writing code for the Windows environment. It'll make life a lot easier in the long run.
Code:
Code:
#pragma comment( lib, "advapi32.lib" )
#include <windows.h>
#include <stdio.h>
int main(void)
{
HKEY hk;
DWORD dwData, dwDisp;
char szKey[] = {"SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU"};
dwData = 1;
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &hk, &dwDisp))
printf("Could not create (open) the szKey registry key.");
else
{
if (RegSetValueEx(hk, // subkey handle
"RebootRelaunchTimeoutEnabled", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
printf("Could not set RebootRelaunchTimeoutEnabled.");
dwData = 1440;
if (RegSetValueEx(hk, // subkey handle
"RebootRelaunchTimeout", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
printf("Could not set RebootRelaunchTimeout.");
RegCloseKey(hk);
}
return 0;
}