Jump to content
Sign in to follow this  
bordomavi

How can i change windows services options with autoit

Recommended Posts

bordomavi

Hi. I want change windows services options. Change settings for automatic or manual or stop services with autoit. Can i build code for this ?

Edited by bordomavi

Share this post


Link to post
Share on other sites
water

There is a Services UDF available.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

Here is the >link.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

Here is the >link.

#include <Services.au3>
_Service_SetStartType
_Service_Stop

Func _Service_Stop("Service1", $sComputerName = "")
    Local $iSSM = _Service_SetStartType($sServiceName, $SERVICE_DISABLED, $sComputerName)
    Return SetError(@error, 0, $iSSM)
EndFunc

i can't use func. can you help me ?

Share this post


Link to post
Share on other sites
water

You need to give us more information.

Do you get any errors?

What is the return value, @error of _Service_SetStartType


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi
ERROR: syntax error
_Service_SetStartType

Share this post


Link to post
Share on other sites
water

Can you please post the whole output from the SciTe output pane?

The error information shows exactly where the error is.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

Can you please post the whole output from the SciTe output pane?

The error information shows exactly where the error is.

i downloaded Services.au3 and SecurityEx.au3 and i write only this to editor

#include <Services.au3>
_Service_SetStartType
_Service_Stop

Func _Service_Stop("Service1", $sComputerName = "")
    Local $iSSM = _Service_SetStartType($sServiceName, $SERVICE_DISABLED, $sComputerName)
    Return SetError(@error, 0, $iSSM)
EndFunc

Share this post


Link to post
Share on other sites
water

When I try your script I get a "Duplicate function name." error message. Looks like the function is already defined in the UDF.



My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

To disable a service you need something like this:

#RequireAdmin
#include <Services.au3>

$iReturnValue = _Service_Change("SensrSvc", $SERVICE_NO_CHANGE, $SERVICE_DISABLED)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

 

When I try your script I get a "Duplicate function name." error message. Looks like the function is already defined in the UDF.


i want just stop service and change startup options.

Share this post


Link to post
Share on other sites
water

Then try to stop and modify service "SensrSvc" as an example:

#RequireAdmin
#include <Services.au3>

$sServiceName = "SensrSvc"
$iReturnValue = _Service_Stop($sServiceName)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
$iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

it change startup. and i want stop service. and enable startup.

Share this post


Link to post
Share on other sites
water

This shouldn't be too hard for you to do it yourself. Given the example code I've already posted.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

yes but you write _Service_Stop but it does not stop servicei it chagnes startup

Share this post


Link to post
Share on other sites
water

Then check the return value of _Service_Stop and only proceed if it was successful.

#RequireAdmin
#include <Services.au3>

$sServiceName = "SensrSvc"
$iReturnValue = _Service_Stop($sServiceName)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
If $iReturnValue = 1 Then
    $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED)
    ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
EndIf
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
bordomavi

 

Then check the return value of _Service_Stop and only proceed if it was successful.

#RequireAdmin
#include <Services.au3>

$sServiceName = "SensrSvc"
$iReturnValue = _Service_Stop($sServiceName)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
If $iReturnValue = 1 Then
    $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED)
    ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
EndIf

and last question. how can i start service and chang startup for automatic

Share this post


Link to post
Share on other sites
0xdefea7

_Service_SetType
_Service_Start

Share this post


Link to post
Share on other sites
bordomavi

_Service_SetType

_Service_Start

#RequireAdmin
#include <Services.au3>
$sServiceName = "TeamViewer8"

$iReturnValue = _Service_Stop($sServiceName)
ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
If $iReturnValue = 1 Then
    $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED)
    ConsoleWrite($iReturnValue & "-" & @error & @CRLF)
EndIf

the service's startup type not change. it is disabled. i want change it to automatic.

Share this post


Link to post
Share on other sites
water

Now I think it is time you try something yourself!

Open the UDF, locate function _Service_Change and read the function header. Has all the needed information. Change $SERVICE_DISABLED to the value needed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×