shital Posted October 8, 2019 Share Posted October 8, 2019 Start process from service window Link to comment Share on other sites More sharing options...
Developers Jos Posted October 8, 2019 Developers Share Posted October 8, 2019 Care to elaborate on that as it doesn't much sense yet? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
shital Posted October 8, 2019 Author Share Posted October 8, 2019 Script should check after some time process status if it is stop then start it on remote pc . process should start from service window as by run command that particular process not starting . ShellExecute("C:\Windows\System32\en-US\services.msc") use for open service but how to select particular service i didnt get that Link to comment Share on other sites More sharing options...
Subz Posted October 8, 2019 Share Posted October 8, 2019 Have a look at SC via command prompt, you can query, start, stop or configure services directly via CMD. Alternatively search the forums for a services udf, I know there have been a few made by various forum members. Link to comment Share on other sites More sharing options...
shital Posted October 8, 2019 Author Share Posted October 8, 2019 Software nt run from command prompt.it's process nt start by hitting exe as installation of it's different . options only to go to service n start tht process ..I didn't get how to click on tht particular process in service windows bec by recorder it nt show process entry . Link to comment Share on other sites More sharing options...
Earthshine Posted October 9, 2019 Share Posted October 9, 2019 The sc command is for manipulating services My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
shital Posted October 10, 2019 Author Share Posted October 10, 2019 Actually , net start "Processing Service" these command i want use in autoit script. $servicename="give me a name please" Run (@comspec & ' /c sc query '&$servicename, '', @sw_hide) these not working for me .might be im doing something wrong . Link to comment Share on other sites More sharing options...
Earthshine Posted October 10, 2019 Share Posted October 10, 2019 (edited) beats me post your code Edited October 10, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
shital Posted October 10, 2019 Author Share Posted October 10, 2019 $servicename=" Processing Service" Run (@comspec & ' /c sc query '&$servicename, '', @sw_hide) Link to comment Share on other sites More sharing options...
Earthshine Posted October 10, 2019 Share Posted October 10, 2019 (edited) try this you are going to need to be administrator though or it gets Access Denied here is your starter script #RequireAdmin #RequireAdmin run("cmd.exe /c sc query "&$servicename, "", @SW_HIDE) run("cmd.exe /c sc stop "&$servicename, "", @SW_HIDE) Edited October 10, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Subz Posted October 10, 2019 Share Posted October 10, 2019 Have a look at the following thread, which shows you how to get the status of a service, I prefer the WMI approach, just use it in an if statement and use SC to start/stop the service. Link to comment Share on other sites More sharing options...
shital Posted October 11, 2019 Author Share Posted October 11, 2019 (edited) #include <Constants.au3> #include <MsgBoxConstants.au3> global $servicename="AppMgmt" global $user="shital" global $pw="" global $sCommand = "run(cmd.exe /c sc query &$servicename, "", @SW_HIDE)" global $iPID = Runas($user, @LogonDomain, $pw, "",@ComSpec & " /c " & $sCommand,"",@SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) global $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput) its nt working any syntax error Edited October 17, 2019 by shital Link to comment Share on other sites More sharing options...
Subz Posted October 11, 2019 Share Posted October 11, 2019 As I mentioned follow the link I posted above, it includes an SC Query example + WMI example, all you have to do is change the service name. Link to comment Share on other sites More sharing options...
shital Posted October 12, 2019 Author Share Posted October 12, 2019 (edited) Thanks Edited October 12, 2019 by shital Link to comment Share on other sites More sharing options...
shital Posted October 12, 2019 Author Share Posted October 12, 2019 (edited) I have modify above code. as code should work for remote pc . When i remove expandcollapse popupMsgBox(0, $service, _RetrieveServiceState("shital-PC", $service)) process not start .I didnt get that .Also I dont want manually click on messagebox as it will inside webDriver script .Any help regarding it #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_type=a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Process.au3> $service = "AppMgmt" $s_Machine="shital-PC" $s_ServiceName="AppMgmt" MsgBox(0, $service, _RetrieveServiceState("shital-PC", $service)) Func _RetrieveServiceState($s_Machine, $s_ServiceName) Local Const $wbemFlagReturnImmediately = 0x10 Local Const $wbemFlagForwardOnly = 0x20 Local $colItems = "", $objItem Local $usr = "", $pass = ""; set this only if different from current user Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") Local $objWMIService = $objWMILocator.ConnectServer($s_Machine, "\root\cimv2", $usr, $pass, "", "", "&H80") If @error Then MsgBox(16, "_RetrieveServiceState", "ObjGet Error: winmgmts") Return EndIf $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name = '" & $s_ServiceName & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If @error Then MsgBox(16, "_RetrieveServiceState", "ExecQuery Error: SELECT * FROM Win32_Service") Return EndIf If IsObj($colItems) Then $StartService = _RunDos("net start AppMgmt") EndIf EndFunc ;==>_RetrieveServiceState Edited October 17, 2019 by shital Link to comment Share on other sites More sharing options...
shital Posted October 13, 2019 Author Share Posted October 13, 2019 How to click on ok button of MsgBox(0, $service, _RetrieveServiceState("shital-PC", $service)) when ok button click then only service get start . i tried winactive,controlclick,mouseclick,send ({enter}) nothing work plz help Link to comment Share on other sites More sharing options...
Subz Posted October 13, 2019 Share Posted October 13, 2019 Just replace the line with _RetrieveServiceState("shital-PC", $service) Link to comment Share on other sites More sharing options...
shital Posted October 14, 2019 Author Share Posted October 14, 2019 (edited) Thanks,it working . #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_type=a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Process.au3> global $service = "AppMgmt" global $s_Machine="shital-PC" global $s_ServiceName="AppMgmt" call(_RetrieveServiceState("shital-PC", $s_ServiceName)) Func _RetrieveServiceState($s_Machine, $s_ServiceName) Local $colItems = "", $objItem Local Const $wbemFlagReturnImmediately = 0x10 Local Const $wbemFlagForwardOnly = 0x20 If Not Ping("shital-PC") Then Return SetError(1, 0, "") Local $usr = "", $pass = ""; set this only if different from current user Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") Local $objWMIService = $objWMILocator.ConnectServer($s_Machine, "\root\cimv2", $usr, $pass, "", "", "&H80") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name = '" & $s_ServiceName & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then $StartService = _RunDos("net start AppMgmt") EndIf EndFunc ;==>_RetrieveServiceState Edited October 17, 2019 by shital Link to comment Share on other sites More sharing options...
shital Posted October 17, 2019 Author Share Posted October 17, 2019 I need one more help my service name is processing service .it's has space so it's nt running Link to comment Share on other sites More sharing options...
Earthshine Posted October 17, 2019 Share Posted October 17, 2019 (edited) please, can you use the code tags when you post code? you click on the thing that looks like this: <> and put your code in there. that way it's all nicely formatted and easier to read #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_type=a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Process.au3> global $service = "AppMgmt" global $s_Machine="shital-PC" global $s_ServiceName="AppMgmt" call(_RetrieveServiceState("shital-PC", $s_ServiceName)) Func _RetrieveServiceState($s_Machine, $s_ServiceName) Local $colItems = "", $objItem Local Const $wbemFlagReturnImmediately = 0x10 Local Const $wbemFlagForwardOnly = 0x20 If Not Ping("shital-PC") Then Return SetError(1, 0, "") Local $usr = "", $pass = ""; set this only if different from current user Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") Local $objWMIService = $objWMILocator.ConnectServer($s_Machine, "\root\cimv2", $usr, $pass, "", "", "&H80") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name = '" & $s_ServiceName & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then $StartService = _RunDos("net start AppMgmt") EndIf EndFunc ;==>_RetrieveServiceState Edited October 17, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now