best way to stop and start services in Win Env.
Hello all!
I have a question. I need to create a small program, either VBS or an Application that will start or stop two services in OS. Those two services would be the same all the time. Any suggestions on what would be the more efficient way of doing it and what technology would you use. Would you create a small .net application or create a batch file or VBS?
Thanks
I have a question. I need to create a small program, either VBS or an Application that will start or stop two services in OS. Those two services would be the same all the time. Any suggestions on what would be the more efficient way of doing it and what technology would you use. Would you create a small .net application or create a batch file or VBS?
Thanks
0 Comments
[ + ] Show comments
Answers (21)
Please log in to answer
Posted by:
yarborg
17 years ago
Psservice from Systernals (Microsoft now) would be my choice. You just pass it a command line parameter of the name of the service and the action to perform. Really simple and proven to work well.
Posted by:
xaviorpl
17 years ago
Thank you very much for your quick response. To give you a little more details, user will execute that script to stop and start services on a "server" not workstations. Would the program you mentioned be able to handle that? Also remember user will only have a right to execute the script and user is not an admin to the box.
Please advice.
Please advice.
Posted by:
AngelD
17 years ago
Posted by:
AngelD
17 years ago
Posted by:
xaviorpl
17 years ago
Well, i am working on this particular application and i need to package it. That's the first part. Now in order for the user to be able to use the package, they need two services on remote servers to start and stop whenever user request them.
I'll create some kind of an application with the shortcut in a start mentu for start and stop, so they could click on them and specific action would be performed. Once again users would be on locked down PC.
Hope that helps.
Thanks,
I'll create some kind of an application with the shortcut in a start mentu for start and stop, so they could click on them and specific action would be performed. Once again users would be on locked down PC.
Hope that helps.
Thanks,
Posted by:
yarborg
17 years ago
Posted by:
xaviorpl
17 years ago
Posted by:
yarborg
17 years ago
Posted by:
AngelD
17 years ago
I would use CPAU for this and it's free.
Although I wouldn't rely 100% on the encryption. If they want to crack it they will eventually.
http://www.joeware.net/freetools/tools/cpau/index.htm
Although I wouldn't rely 100% on the encryption. If they want to crack it they will eventually.
http://www.joeware.net/freetools/tools/cpau/index.htm
Posted by:
xaviorpl
17 years ago
I am not sure if i was clear enough with my little project but the deal is user on locked down PC wants to be able to start or stop a service on a remote server. Have you guys done anything similar to that. It would be easier to do that on the same PC but we're talking about remote server.
What would be the best technology to achieve that. Would any of you try to write a perl script or you would go along with either VB or any ther tools?
Thanks,
What would be the best technology to achieve that. Would any of you try to write a perl script or you would go along with either VB or any ther tools?
Thanks,
Posted by:
xaviorpl
17 years ago
AngeID,
Net start/stop cannot be used remotedly is that right? SC can be used remotedly but user need to have admin rights to the workstation it is stopping the service on. That's part of my problem, user will not have the rights on the remote pc, therefore
- there will be an administrator account on the box which i could use to pass the parameters but with that there is the risk of someone else getting their hands on the password unless i'll try to hide it somehow.
Net start/stop cannot be used remotedly is that right? SC can be used remotedly but user need to have admin rights to the workstation it is stopping the service on. That's part of my problem, user will not have the rights on the remote pc, therefore
- there will be an administrator account on the box which i could use to pass the parameters but with that there is the risk of someone else getting their hands on the password unless i'll try to hide it somehow.
Posted by:
AngelD
17 years ago
For managing service on a remove server I would use PsService as yarborg mentioned before to remotely manage the service.
You can find this tool at http://www.microsoft.com/technet/sysinternals/utilities/psservice.mspx
To encrypt it use CPAU so the account and password information will not be visible in plain text.
However I would never allow "normal" users to manage service on a server or any other task.
Why can't you just leave that service running at all time?
You can find this tool at http://www.microsoft.com/technet/sysinternals/utilities/psservice.mspx
To encrypt it use CPAU so the account and password information will not be visible in plain text.
However I would never allow "normal" users to manage service on a server or any other task.
Why can't you just leave that service running at all time?
Posted by:
xaviorpl
17 years ago
I understand you concern and i agree with you. However i am being forced to develop "something" that would allow normal users using this particular application to just click on "start" button and be able to start 2 specific services and upon pressing stop those exactly the same services would stop. One of my requirements is that users will not have admin rights to the server where those services would start or stop.
Keep in mind they would only start or stop those services when running special reports. For some reason the software they have is generating wrong reports when those services run and different part of the software requires those services to be running in order to produce "different" report. I know it sounds strange but that's all i have at this point.
I'll investigate the last link you provided me with tomorrow.
Thanks,
Keep in mind they would only start or stop those services when running special reports. For some reason the software they have is generating wrong reports when those services run and different part of the software requires those services to be running in order to produce "different" report. I know it sounds strange but that's all i have at this point.
I'll investigate the last link you provided me with tomorrow.
Thanks,
Posted by:
xaviorpl
17 years ago
AngelD,
i have a question. How would i use CPAU in this scenerio:
c:\temp>psservice.exe \\197.54.444.123 -u xavior -p xavior start service_name
In that case psservice.exe and CPAU.exe both are located in temp folder, and i am starting a service on a remote computer with 197.54.444.123 IP. How can i run CPAU on the top of that?
Thanks
i have a question. How would i use CPAU in this scenerio:
c:\temp>psservice.exe \\197.54.444.123 -u xavior -p xavior start service_name
In that case psservice.exe and CPAU.exe both are located in temp folder, and i am starting a service on a remote computer with 197.54.444.123 IP. How can i run CPAU on the top of that?
Thanks
Posted by:
AngelD
17 years ago
When I used this I created a .cmd file with the command I wanted to execute.
ex. psservice.cmd
@echo off
psservice.exe \\197.54.444.123 start service_name
To create a "JOB" file use:
\\server\share\path\cpau.exe -u domain\xavior -p xavior -ex "\\server\share\path\psservice.cmd" -file \\server\share\path\psservice.cpau -enc -crc \\server\share\path\psservice.cmd
To execute the "JOB" file use:
\\server\share\path\cpau -file \\server\share\path\psservice.cpau -dec -profile
Hope it helps.
ex. psservice.cmd
@echo off
psservice.exe \\197.54.444.123 start service_name
To create a "JOB" file use:
\\server\share\path\cpau.exe -u domain\xavior -p xavior -ex "\\server\share\path\psservice.cmd" -file \\server\share\path\psservice.cpau -enc -crc \\server\share\path\psservice.cmd
To execute the "JOB" file use:
\\server\share\path\cpau -file \\server\share\path\psservice.cpau -dec -profile
Hope it helps.
Posted by:
xaviorpl
17 years ago
Posted by:
xaviorpl
17 years ago
AngelD,
Analyzing those 4 lines,
To create a "JOB" file use:
\\server\share\path\cpau.exe -u domain\xavior -p xavior -ex "\\server\share\path\psservice.cmd" -file \\server\share\path\psservice.cpau -enc -crc \\server\share\path\psservice.cmd
That would create the following file: psservice.cpau is that correct ?
Then the second part
\\server\share\path\cpau -file \\server\share\path\psservice.cpau -dec -profile
would just execute it right? What about -dec and -profile, what's that for.
Sorry if those questions don't make sense but i am new to that .
Thanks
Analyzing those 4 lines,
To create a "JOB" file use:
\\server\share\path\cpau.exe -u domain\xavior -p xavior -ex "\\server\share\path\psservice.cmd" -file \\server\share\path\psservice.cpau -enc -crc \\server\share\path\psservice.cmd
That would create the following file: psservice.cpau is that correct ?
Then the second part
\\server\share\path\cpau -file \\server\share\path\psservice.cpau -dec -profile
would just execute it right? What about -dec and -profile, what's that for.
Sorry if those questions don't make sense but i am new to that .
Thanks
Posted by:
AngelD
17 years ago
You cannot created and execute it at the same time?
No
That would create the following file: psservice.cpau is that correct ?
Yes
would just execute it right?
Yes
What about -dec and -profile, what's that for.
Run CPAU /? to find out about the available arguments and some examples.
-dec
As you encrypted (-enc) the JOB file -dec will tell to execute an encrypted JOB file
-profile
Do local logon with profile instead of net logon
No
That would create the following file: psservice.cpau is that correct ?
Yes
would just execute it right?
Yes
What about -dec and -profile, what's that for.
Run CPAU /? to find out about the available arguments and some examples.
-dec
As you encrypted (-enc) the JOB file -dec will tell to execute an encrypted JOB file
-profile
Do local logon with profile instead of net logon
Posted by:
xaviorpl
17 years ago
AngelD,
Thanks alot you've been very helpful. Do i have to create "job" each time or i can create it once and use it all the time since server name etc won't change?
Do you know of a way to find out about the status of the request after running those commands? It might take some time for the service to start or stop. Is it possible with something simple or that would be more sophisticated task?
Thanks
Thanks alot you've been very helpful. Do i have to create "job" each time or i can create it once and use it all the time since server name etc won't change?
Do you know of a way to find out about the status of the request after running those commands? It might take some time for the service to start or stop. Is it possible with something simple or that would be more sophisticated task?
Thanks
Posted by:
xaviorpl
17 years ago
AngelD,
I created .cmd file, tested it with user name and password inside, worked fine. I removed user name and password and proceded to creating job file. That created the .cpau file then i was able to run it , "the command completed successfully". Only problem i don't see the service being started or stopped on my test PC. It was workign fine with the .cmd file alone (with user name and password) but once i execute .cpau file it is not working and i am getting a message that it was successfully completed.
Any suggestions on why that is happening?
Thanks,
I created .cmd file, tested it with user name and password inside, worked fine. I removed user name and password and proceded to creating job file. That created the .cpau file then i was able to run it , "the command completed successfully". Only problem i don't see the service being started or stopped on my test PC. It was workign fine with the .cmd file alone (with user name and password) but once i execute .cpau file it is not working and i am getting a message that it was successfully completed.
Any suggestions on why that is happening?
Thanks,
Posted by:
xaviorpl
17 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.