Siege Posted October 22, 2009 Share Posted October 22, 2009 Hi, can someone show me how I can write a script that will start a service automatically. For example when I turn on my computer I want a service to start automatically. Link to comment Share on other sites More sharing options...
prologician Posted October 22, 2009 Share Posted October 22, 2009 (edited) For sure you can do this using COM objects.... I don't know if there's a UDF which already touches on this.In any case, you might want to take a look at this webpage.In a script, it'll look like...$oShell = ObjCreate("shell.application") if not $oShell.IsServiceRunning("") then $oShell.ServiceStart("") endifThere's probably an easier way, though...EDIT: If you're wanting to start the service automatically when the computer starts... why not adjust those settings in the Administrative Tools control panel? Or does that not work for some reason? Edited October 22, 2009 by prologician Link to comment Share on other sites More sharing options...
Siege Posted October 22, 2009 Author Share Posted October 22, 2009 My avast! Antivirus service is stopped every time I restart my computer. I have set the service to Automatic but still every time I start up my computer it turns itself off. Therefore I thought I could write a script that automatically turned the service on whenever I turned on my computer. But if you have any suggestions that would be better I would be happy to know.And thanks for the reply. Link to comment Share on other sites More sharing options...
jvanegmond Posted October 22, 2009 Share Posted October 22, 2009 http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_start.mspx?mfr=true Works on other OS too. Make sure you have admin priviledges. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Juvigy Posted October 22, 2009 Share Posted October 22, 2009 You can use CMD commands: net stop "servicename" net start "servicename" Link to comment Share on other sites More sharing options...
yucatan Posted October 22, 2009 Share Posted October 22, 2009 just install a good virus scanner "problem solved" Link to comment Share on other sites More sharing options...
jvanegmond Posted October 22, 2009 Share Posted October 22, 2009 just install a good virus scanner "problem solved"Keep your opinions to yourself. They are not helping in this thread.If you must share your opinion, take it to the Chat forum. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Siege Posted October 22, 2009 Author Share Posted October 22, 2009 You can use CMD commands:net stop "servicename"net start "servicename"This worked just as I wanted, I made the cmd command to a batch file. I also added: "@echo off" in the start of the bat file but it stills displays the cmd window when I press the batch file?How can I get the batch file to execute itself without displaying it? Link to comment Share on other sites More sharing options...
jvanegmond Posted October 22, 2009 Share Posted October 22, 2009 Run("net start ""service name""") github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now