I need some help to create service on remote machine
the code i tested:
it seems not to work, if anyone can help i can send btc for it too, i just need to start my exe on remote machine.
the code i tested:
Код:
bool CreateRemoteService(
const wchar_t* remoteMachine,
const wchar_t* serviceName,
const wchar_t* displayName,
const wchar_t* executablePath,
const wchar_t* user,
const wchar_t* password
) {
// Open a handle to the SCM on the remote machine
SC_HANDLE schSCManager = OpenSCManagerW(remoteMachine, NULL, SC_MANAGER_CREATE_SERVICE);
if (schSCManager == NULL) {
return false;
}
// Create the service
SC_HANDLE schService = CreateServiceW(
schSCManager, // SCM database
serviceName, // name of service
displayName, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
executablePath, // path to service's binary
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
user, // account name
password // account password
);
if (schService == NULL) {
CloseServiceHandle(schSCManager);
return false;
}
// Start the service
if (!StartService(schService, 0, NULL)) {
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
return false;
}
// Close handles
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
return true;
}
it seems not to work, if anyone can help i can send btc for it too, i just need to start my exe on remote machine.