Jump to content

Recommended Posts

Posted

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.

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
Posted

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.

Posted

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?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...