Jump to content
shital

Start process from service window

Recommended Posts

Thanks  i wasnt aware of it . Can any one please help me for space issue my code still pending .

Share this post


Link to post
Share on other sites

Put quotes around the service name.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
$StartService = _RunDos(' net start "CryptSvc"  ' )

my service name  " XYX   Processing service"

its nt working above command what mistake in syntax

Edited by shital

Share this post


Link to post
Share on other sites

You can use the Windows Services UDF to work with services, instead of the command line.  A few examples are below.  

Using the known service name and computer.

#RequireAdmin
#include <Services.au3>

Global $sServiceName = "AppMgmt"
Global $sComputer = "shital-PC"

;Check the status of the service, if it is stopped, start it.  
Global $aService = 0
Do
    $aService = _Service_QueryStatus($sServiceName, $sComputer)
    If @error Then Exit 1
    
    If $aService[1] = $SERVICE_STOPPED Then 
        If Not _Service_Start($sServiceName, $sComputer) Then Exit 2
    EndIf
    
    Sleep(500) ;Wait 500 ms.
Until $aService[1] = $SERVICE_RUNNING

Using known service display name and computer.  

#RequireAdmin
#include <Array.au3>
#include <Services.au3>

Global $sComputer = "shital-PC"

;Get a list of all services.
Global $aServices = _Service_Enum($SERVICE_WIN32, $SERVICE_STATE_ALL, Default, $sComputer)
If @error Then Exit 1

;Search for the service display name.
Global $sSearch = "XYX Processing service"

Global $aFound = _ArrayFindAll($aServices, $sSearch, 1, 0, 0, 1, 1) ;Starting with row 1, partial search, 2D array column 1.
If @error Then Exit 1 + @error

;If more than one service is found, exit.
If UBound($aFound) > 1 Then Exit 8

;Get service name from found service display name.
Global $sServiceName = $aServices[$aFound[0]][0]

;Check the status of the service, if it is stopped, start it.  
Global $aService = 0
Do
    $aService = _Service_QueryStatus($sServiceName, $sComputer)
    If @error Then Exit 9
    
    If $aService[1] = $SERVICE_STOPPED Then 
        If Not _Service_Start($sServiceName, $sComputer) Then Exit 10
    EndIf
    
    Sleep(500) ;Wait 500 ms.
Until $aService[1] = $SERVICE_RUNNING

 

Adam

 

Edited by AdamUL

Share this post


Link to post
Share on other sites

That's not enough detail to go on.  What are you getting from _Service_QueryStatus?  _Service_QueryStatus returns an array.  

 

Adam

 

Share this post


Link to post
Share on other sites

I guess im not getting your code.for running first code it showing 

#include <Services.au3> undefine .

if possible can u plz  describe Services.au3 not library  then which file is Services.au3

Edited by shital

Share this post


Link to post
Share on other sites

Thanks found code 

One more things   it open window poup and ask for allow autoit program  tp run .is that anyway to suppress it ?

Share this post


Link to post
Share on other sites

This is due to the #RequireAdmin directive causing a UAC prompt.  How do you plan to deploy the script?  This determines how, and if you need to suppress the prompt.  

 

Adam

 

Share this post


Link to post
Share on other sites

Actually ,

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_type=a3x
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Services.au3>

Global $sServiceName = "Intell Processing Service"
Global $sComputer = "el66"

;Check the status of the service, if it is stopped, start it.
Global $aService = 0
Do
    $aService = _Service_QueryStatus($sServiceName, $sComputer)
    If @error Then Exit 1

    If $aService[1] = $SERVICE_STOPPED Then
        If Not _Service_Start($sServiceName, $sComputer) Then Exit 2
    EndIf

    Sleep(500) ;Wait 500 ms.
Until $aService[1] = $SERVICE_RUNNING

These code not working due to service name space . That same issue it wasn't solved  yet and  other  code run exe but  my services not start with exe it work with sc or net start .My point is i want check service running or not after some interval and if its not work again  service should start on remote pc .

Share this post


Link to post
Share on other sites

Try this for the spaces in the name issue.

Global $sServiceName = '"Intell Processing Service"'

I added quotes around the service name.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Are you sure that is the service name, and not the service display name?  The UDF needs the service name to work.  This script searches for the service name based on its display name.  I posted this above, but I'll include it here with the update information you gave.  You need admin rights on the remote PC for it to work.  

#RequireAdmin
#include <Array.au3>
#include <Services.au3>

Global $sComputer = "el66"

;Get a list of all services.
Global $aServices = _Service_Enum($SERVICE_WIN32, $SERVICE_STATE_ALL, Default, $sComputer)
If @error Then Exit 1

;Search for the service display name using partial name.
Global $sSearch = "Intell Processing"

Global $aFound = _ArrayFindAll($aServices, $sSearch, 1, 0, 0, 1, 1) ;Starting with row 1, partial search, 2D array column 1.
If @error Then Exit 1 + @error

;If more than one service is found, exit.
If UBound($aFound) > 1 Then Exit 8

;Get service name from found service display name.
Global $sServiceName = $aServices[$aFound[0]][0]

;Check the status of the service, if it is stopped, start it.  
Global $aService = 0
Do
    $aService = _Service_QueryStatus($sServiceName, $sComputer)
    If @error Then Exit 9
    
    If $aService[1] = $SERVICE_STOPPED Then 
        If Not _Service_Start($sServiceName, $sComputer) Then Exit 10
    EndIf
    
    Sleep(100) ;Wait 100 ms.
Until $aService[1] = $SERVICE_RUNNING

Or you can check the service name with the service.msc and it properties.  Example below.  The service name is highlighted.  

783843399_ServiceProperties.png.01bf5149a41f86d50444fbf781fb731e.png

 

Adam

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

×
×
  • Create New...