Jump to content

new to AutoIt and scripting - Services


Recommended Posts

Hi all,

I'm new to AutoIt and to scripting in general. I'm a SysAdmin but the most i can do with scripting is a bunch of batch files and that's it. :D

So i decided to start learning a bit about this, since it can help me save a lot of time in simple stuff, that is repetitive and time consuming, and i can adapt scripts to my needs.

Today I've been reading the tutorials and playing around a bit with a small script that i want to be able to stop a service on a remote computer. Let's say I want to stop the Alerter service at "Computer1"

This is where I'm at:

$answer = InputBox("Managing Services", "Target Computer", "Computer1", "", _
    -1, -1, 0, 0)
; Stop Alerter Service
 unWait("sc "$answer" stop Alerter", "C:\windows\system32")

I was expecting that whatever I typed in the box would be used as the computer name...I'm clearly doing something wrong, and something very basic I'm sure...just can't figure out what...

Any hints?

Ideally I would want to have a script that would let me start and stop services on remote machines, by typing their name in a text field, but...slowly i'll get there because i want to learn my way and not just have it working without knowing how it's done.

Thanks in advance for any help.

Link to comment
Share on other sites

Hi all,

I'm new to AutoIt and to scripting in general. I'm a SysAdmin but the most i can do with scripting is a bunch of batch files and that's it. :D

So i decided to start learning a bit about this, since it can help me save a lot of time in simple stuff, that is repetitive and time consuming, and i can adapt scripts to my needs.

Today I've been reading the tutorials and playing around a bit with a small script that i want to be able to stop a service on a remote computer. Let's say I want to stop the Alerter service at "Computer1"

This is where I'm at:

$answer = InputBox("Managing Services", "Target Computer", "Computer1", "", _
    -1, -1, 0, 0)
; Stop Alerter Service
 unWait("sc "$answer" stop Alerter", "C:\windows\system32")

I was expecting that whatever I typed in the box would be used as the computer name...I'm clearly doing something wrong, and something very basic I'm sure...just can't figure out what...

Any hints?

Ideally I would want to have a script that would let me start and stop services on remote machines, by typing their name in a text field, but...slowly i'll get there because i want to learn my way and not just have it working without knowing how it's done.

Thanks in advance for any help.

Your code has an error:

$answer = InputBox("Managing Services", "Target Computer", "Computer1", "", -1, -1, 0, 0)
; Stop Alerter Service
RunWait("sc " & $answer & " stop Alerter", "C:\windows\system32")

You need to seperate the $variable from the "string" like I've done compared to yours.

Edited by Cynagen

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Link to comment
Share on other sites

Your code has an error:

$answer = InputBox("Managing Services", "Target Computer", "Computer1", "", -1, -1, 0, 0)
; Stop Alerter Service
RunWait("sc " & $answer & " stop Alerter", "C:\windows\system32")

You need to seperate the $variable from the "string" like I've done compared to yours.

the R was missing on my first post.

I ended up adding the \\ so i don't have to type it on the computer name everytime.

this is how it looks...and it works! Thanks.

RunWait("sc \\" & $answer & " stop Alerter", "C:\windows\system32")

I'll post updates as my little script starts growing (and probably bug people some more along the way... )

Link to comment
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
 Share

  • Recently Browsing   0 members

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