PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Service Start/Stop/Restart from a remote PC
Service Start/Stop/Restart from a remote PC
Iniciado por guest, 17,may. 2016 08:52 - 4 respuestas
Publicado el 17,mayo 2016 - 08:52
Hi everyone,
I've tried the Windev functions for doing what I've written in the subject of this topic (ServiceStart/ServiceStop/ServiceRestart) on a local machine, and it worked pretty well. My next step is to try to run these from a Client PC, in order to handle the specified service on the Server PC. Following the Windev's guide, it says that to use any of these functions, the user must be an administrator on the remote PC, and in my case, he can't be one... I wonder, is there another way to shut down/start up a service on a remote PC? Am I missing something about these functions, like some parameters that i've missed other than the name of the service and the IP of the remote computer?
TIA
Publicado el 17,mayo 2016 - 09:41
Hi,

All the WX functions do is interact with the Windows API's for managing services.
I never use the WX functions but use the SC command instead to create, remove, start, stop, restart services etc...
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682107(v=vs.85).aspx

It is important that the user that runs the command (if it be the WX command or the SC command) has sufficient privileges on the remote machine to do so.

I assume your computers are part of an AD domain. If so, make sure the user logged on to the machine executing the script to do something on a remote machine has sufficient privileges on that remote machine to do so what you want. If the machine is not part of an AD domain I guess you'll first have to do some sort of logon to that machine with a user profile of that machine that has sufficient privileges.

Just my 2 cents,

Peter Holemans
Publicado el 17,mayo 2016 - 10:28
Hi Peter,
thank you for your quick and exhaustive answer.
That "logon" that you're talking about is something that i'm very interested in, and i'm currently studying a way to do so, maybe with a webservice installed on the same pc that runs the service... Is there a Windows API or some Windev functions for handling Windows users?
Publicado el 17,mayo 2016 - 14:04
Hello Yaku

there is a quite simple way around it...

You don't want to give admin privileges to your user, you just want him to have THAT specific right...

So, create a service on the server. This server will monitor something (like a file on disk or a record in a DB)
Your user will simply write this file or record (it can be encrypted, with a very specific syntax) by using a small program installed on his pc
When the service sees the flag, it will start/stop the other service (and it will be able to do so because it will have the corresponding rights)

Best regards
Publicado el 17,mayo 2016 - 14:59
you can try with ExeRemoteRun function using another user/password. try to run the SC command in the machine with the service.

http://doc.windev.com/en-US/…