Sign in to follow this  
Followers 0
Siege

How do I write a script that can start a service for me?

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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("")
endif

There'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 by prologician

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You can use CMD commands:

net stop "servicename"

net start "servicename"

Share this post


Link to post
Share on other sites

just install a good virus scanner "problem solved"

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0