Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/10/2024 in all areas

  1. I found out the error is due to Zscaler (It’s a bundle of security services. ZScaler Internet Access proxies your Internet traffic and runs it through URL content filter lists.). Basically it detects my x86 exe having trojan thus it restricted the upload.
    2 points
  2. I don't think I needed to create a new topic 10 years later but just an FYI. I've been struggling over this for a while and just accepting how I thought it worked. For anyone interested who might have missed it in the documentation. I really like using #Regions to organize my code so now I found a trick when I have multiple functions in a single region open in Scite: The trick I recently learned is to Ctrl+Click the #Region as you fold it to keep the children folded. This way when you can just Click to unfold the #Region and it will leave the child functions folded.
    1 point
  3. Here is my attempt adjust the title $sTitle = "Μaps Google — Mozilla Firefox" depending on your language and browser with the arrows choose a direction and with the keys from the numeric keypad 0 = Pause 1, 4 = adjust how long is the drag step 2, 5 = adjust the speed of the drag step ; https://www.autoitscript.com/forum/topic/211963-move-a-google-maps-map-slowly-and-fluidly-with-a-routine/#comment-1534613 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <AutoItConstants.au3> #include <Misc.au3> Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info Global $sTitle = "Map Google — Mozilla Firefox" ; *** <-- Customize Global $bInfo = True ; *** <-- ConsoleWrite info If WinExists($sTitle) Then WinActivate($sTitle) Else ShellExecute("https://www.google.com/maps/") EndIf Global $hWnd = WinWaitActive($sTitle, "", 5) DW("$hWnd=" & $hWnd & @CRLF) Global $iSpeed = 10 Global $iStep = 10 Global $iDirection = 0 Global $aMPoint[2] = [@DesktopWidth * 0.9, @DesktopHeight * 0.8] ;DragPoint DW("DragPoint=" & $aMPoint[0] & ", " & $aMPoint[1] & @CRLF) While WinExists($hWnd) If $sTitle = WinGetTitle("[ACTIVE]") Then ;Register HotKeys HotKeySet("{ESC}", "Direction") ;Exit HotKeySet("{NUMPAD0}", "Direction") ;$iDirection = 0 => Pause HotKeySet("{UP}", "Direction") ;$iDirection = 1 HotKeySet("{DOWN}", "Direction") ;$iDirection = 2 HotKeySet("{RIGHT}", "Direction") ;$iDirection = 3 HotKeySet("{LEFT}", "Direction") ;$iDirection = 4 HotKeySet("{NUMPAD4}", "Direction") ;$iStep + HotKeySet("{NUMPAD1}", "Direction") ;$iStep - HotKeySet("{NUMPAD5}", "Direction") ;$iSpeed + HotKeySet("{NUMPAD2}", "Direction") ;$iSpeed - Else ;UnRegister HotKeys HotKeySet("{ESC}") HotKeySet("{NUMPAD0}") HotKeySet("{UP}") HotKeySet("{DOWN}") HotKeySet("{RIGHT}") HotKeySet("{LEFT}") HotKeySet("{NUMPAD4}") HotKeySet("{NUMPAD1}") HotKeySet("{NUMPAD5}") HotKeySet("{NUMPAD2}") EndIf ;********************************** While $sTitle = WinGetTitle("[ACTIVE]") Switch $iDirection Case 0 ;Pause Sleep(300) Case 1 ;UP MouseMove($aMPoint[0], $aMPoint[1] - $iStep, 0) MouseDown("primary") MouseMove($aMPoint[0], $aMPoint[1] + $iStep, $iSpeed) MouseUp("primary") Case 2 ;DOWN MouseMove($aMPoint[0], $aMPoint[1] + $iStep, 0) MouseDown("primary") MouseMove($aMPoint[0], $aMPoint[1] - $iStep, $iSpeed) MouseUp("primary") Case 3 ;RIGHT MouseMove($aMPoint[0] + $iStep, $aMPoint[1], 0) MouseDown("primary") MouseMove($aMPoint[0] - $iStep, $aMPoint[1], $iSpeed) MouseUp("primary") Case 4 ;LEFT MouseMove($aMPoint[0] - $iStep, $aMPoint[1], 0) MouseDown("primary") MouseMove($aMPoint[0] + $iStep, $aMPoint[1], $iSpeed) MouseUp("primary") EndSwitch Sleep(10) WEnd ;********************************** Sleep(500) WEnd DW("- Exit Script" & @CRLF) ;-------------------------------------------------------------------------------------------------------------------------------- Func Direction() DW("- @HotKeyPressed=" & @HotKeyPressed & @CRLF) Switch @HotKeyPressed Case "{ESC}" DW("Exit" & @CRLF) Exit Case "{NUMPAD0}" $iDirection = 0 DW("$iDirection=" & $iDirection & @CRLF) Case "{UP}" $iDirection = 1 DW("$iDirection=" & $iDirection & @CRLF) Case "{DOWN}" $iDirection = 2 DW("$iDirection=" & $iDirection & @CRLF) Case "{RIGHT}" $iDirection = 3 DW("$iDirection=" & $iDirection & @CRLF) Case "{LEFT}" $iDirection = 4 DW("$iDirection=" & $iDirection & @CRLF) Case "{NUMPAD4}" $iStep += 1 $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep) DW("$iStep=" & $iStep & @CRLF) Case "{NUMPAD1}" $iStep -= 1 $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep) DW("$iStep=" & $iStep & @CRLF) Case "{NUMPAD5}" $iSpeed -= 1 $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed) DW("$iSpeed=" & $iSpeed & @CRLF) Case "{NUMPAD2}" $iSpeed += 1 $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed) DW("$iSpeed=" & $iSpeed & @CRLF) EndSwitch EndFunc ;==>Direction ;-------------------------------------------------------------------------------------------------------------------------------- Func DW($sText) If Not $bInfo Then Return ConsoleWrite($sText) EndFunc
    1 point
  4. I understand your concern, but imho it's a very little price to pay. The interpreter "AutoIt3.exe" is less than 1MB size and your friends need to copy it only once, then you can send them... dozen of ".a3x" scripts (joking) and they'll be delighted that everything runs fine each time. Anyway, it's your decision and the cards are in your hands now That's very kind words, really appreciated. I always felt that you got a good heart. My friend, I wish you same, a long, healthy and happy life too
    1 point
  5. @pixelsearch, I,m glad you are back. I was a little bit worried when you didn't show up for several months. I wish you a healthy and happy life.
    1 point
  6. I have old x32 devices too To avoid this issue and for personal use, I always compile my scripts as .a3x so the AV never reacts.
    1 point
  7. This is a great UDF. Thanks! I added a couple of functions to allow me to be able to backup/restore a service configuration and thought I would share back. Add the following to ServicesConstants.au3: Global Const $SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3 Global Const $SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4 Global Const $SERVICE_CONFIG_SERVICE_SID_INFO = 5 Global Const $SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6 Global Const $SERVICE_CONFIG_PRESHUTDOWN_INFO = 7 Global Const $SERVICE_CONFIG_TRIGGER_INFO = 8 Global Const $SERVICE_CONFIG_PREFERRED_NODE = 9 Global Const $SERVICE_CONFIG_LAUNCH_PROTECTED = 12 Global Const $SERVICE_CONFIG_ALL[] = [$SERVICE_CONFIG_DELAYED_AUTO_START_INFO, _ $SERVICE_CONFIG_DESCRIPTION, _ $SERVICE_CONFIG_FAILURE_ACTIONS, _ $SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, _ $SERVICE_CONFIG_PREFERRED_NODE, _ $SERVICE_CONFIG_PRESHUTDOWN_INFO, _ $SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO, _ $SERVICE_CONFIG_SERVICE_SID_INFO, _ $SERVICE_CONFIG_TRIGGER_INFO, _ $SERVICE_CONFIG_LAUNCH_PROTECTED] Global Enum $SC_ACTION_TYPE, $SC_ACTION_DELAY And add the following to Services.au3: #include <Math.au3> ; #FUNCTION# ======================================================================================================================================================= ; Name...........: _Service_ChangeConfig2 ; Description ...: Sets the optional configuration parameters specified in $aInfo and $aInfoLevels for the specified service. ; Syntax.........: _Service_ChangeConfig($sServiceName, $aInfo, $aInfoLevels [, $sComputerName]) ; Parameters ....: $sServiceName - Name of the service. ; $aInfo - Array of configuration settings by InfoLevel index. ; $aInfoLevel - Array of InfoLevels to change the configuration setttings. ; $sComputerName - [Optional] The name of the target computer. The local computer is default. ; Requirement(s).: None. ; Return values .: None. ; Author ........: chinadoug ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================================================================== Func _Service_ChangeConfig2($sServiceName, ByRef $aInfo, Const ByRef $aInfoLevels, $sComputerName = "") Local $hSC, $hService, $dwInfoLevel $hSC = OpenSCManager($sComputerName, $SC_MANAGER_CONNECT) $hService = OpenService($hSC, $sServiceName, BitOR($SERVICE_CHANGE_CONFIG, $SERVICE_START)) For $dwInfoLevel in $aInfoLevels Switch $dwInfoLevel Case $SERVICE_CONFIG_DELAYED_AUTO_START_INFO ; update delayed auto start information Local $fDelayedAutostart = $aInfo[$dwInfoLevel] Local $serviceDelayedAutoStartInfo = DllStructCreate("INT fDelayedAutostart") Local $lpInfo = DllStructGetPtr($serviceDelayedAutoStartInfo) DllStructSetData($serviceDelayedAutoStartInfo, "fDelayedAutostart", $fDelayedAutostart) Case $SERVICE_CONFIG_DESCRIPTION ; update the service description Local $sDescription = $aInfo[$dwInfoLevel] Local $serviceDescription = DllStructCreate("PTR lpDescription") Local $lpInfo = DllStructGetPtr($serviceDescription) Local $lpDescription = DllStructCreate("wchar[" & (StringLen($sDescription)+1) & "]") DllStructSetData($lpDescription, 1, $sDescription) DllStructSetData($serviceDescription, "lpDescription", DllStructGetPtr($lpDescription)) Case $SERVICE_CONFIG_FAILURE_ACTIONS ; update the failure actions Local $aFailureActions = $aInfo[$dwInfoLevel] Local $serviceFailureActions = DllStructCreate("DWORD dwResetPeriod;PTR lpRebootMsg;PTR lpCommand;DWORD cActions;PTR lpsaActions") Local $lpInfo = DllStructGetPtr($serviceFailureActions) Local $dwResetPeriod = $aFailureActions[0] DllStructSetData($serviceFailureActions, "dwResetPeriod", $dwResetPeriod) ; Notes ; if $sRebootMsg = "" then the reboot message will be deleted. ; if $sRebootMsg = Null then the reboot message will not be changed. Local $sRebootMsg = $aFailureActions[1] If Not IsString($sRebootMsg) Then $sRebootMsg = Null Local $lpRebootMsg = DllStructCreate("wchar[" & (StringLen($sRebootMsg)+1) & "]") DllStructSetData($lpRebootMsg, 1, $sRebootMsg) ; Notes ; if $sCommand = "" then the command will be deleted. ; if $sCommand = Null then the command will not be changed. Local $sCommand = $aFailureActions[2] If Not IsString($sCommand) Then $sCommand = Null Local $lpCommand = DllStructCreate("wchar[" & (StringLen($sCommand)+1) & "]") DllStructSetData($lpCommand, 1, $sCommand) ; Notes ; if $cActions = 0 AND $lpsaActions != Null then the values ; for the reset period and any configured failure actions will be deleted. ; if $cActions = 0 AND $lpsaActions = Null then any ; settings for the reset period and failure actions will be ignored. Local $cActions = $aFailureActions[3] Local $tagSC_ACTION = "INT Type;DWORD Delay" Local $itSC_ACTIONSize = DllStructGetSize(DllStructCreate($tagSC_ACTION)) Local $lpsaActions Local $aActions = $aFailureActions[4] If IsArray($aActions) Then Local $tArraySC_ACTION = DllStructCreate("byte[" & (UBound($aActions) * $itSC_ACTIONSize) & "]") For $i = 0 to UBound($aActions)-1 Local $aAction = $aActions[$i] Local $tSC_ACTION = DllStructCreate($tagSC_ACTION, DllStructGetPtr($tArraySC_ACTION) + ($i * $itSC_ACTIONSize)) DllStructSetData($tSC_ACTION, "Type", $aAction[$SC_ACTION_TYPE]) DllStructSetData($tSC_ACTION, "Delay", $aAction[$SC_ACTION_DELAY]) Next $lpsaActions = DllStructGetPtr($tArraySC_ACTION) Else $lpsaActions = Null EndIf DllStructSetData($serviceFailureActions, "lpRebootMsg", ($sRebootMsg = Null ? Null : DllStructGetPtr($lpRebootMsg))) DllStructSetData($serviceFailureActions, "lpCommand", ($sCommand = Null ? Null : DllStructGetPtr($lpCommand))) DllStructSetData($serviceFailureActions, "cActions", $cActions) DllStructSetData($serviceFailureActions, "lpsaActions", $lpsaActions) Case $SERVICE_CONFIG_FAILURE_ACTIONS_FLAG ; update failure actions flag Local $fFailureActionsOnNonCrashFailures = $aInfo[$dwInfoLevel] Local $serviceFailureActionsFlag = DllStructCreate("INT fFailureActionsOnNonCrashFailures") Local $lpInfo = DllStructGetPtr($serviceFailureActionsFlag) DllStructSetData($serviceFailureActionsFlag, "fFailureActionsOnNonCrashFailures", $fFailureActionsOnNonCrashFailures) Case $SERVICE_CONFIG_PREFERRED_NODE ; update preferred node Local $aPreferredNodeInfo = $aInfo[$dwInfoLevel] Local $servicePreferredNodeInfo = DllStructCreate("USHORT usPreferredNode;BOOLEAN fDelete") Local $lpInfo = DllStructGetPtr($serviceFailureActions) Local $usPreferredNode = $aPreferredNodeInfo[0] Local $fDelete = $aPreferredNodeInfo[1] DllStructSetData($servicePreferredNodeInfo, "usPreferredNode", $usPreferredNode) DllStructSetData($servicePreferredNodeInfo, "fDelete", $fDelete) Case $SERVICE_CONFIG_PRESHUTDOWN_INFO ; update preshutdown info Local $dwPreshutdownTimeout = $aInfo[$dwInfoLevel] Local $servicePreshutdownInfo = DllStructCreate("DWORD dwPreshutdownTimeout") Local $lpInfo = DllStructGetPtr($servicePreshutdownInfo) DllStructSetData($servicePreshutdownInfo, "dwPreshutdownTimeout", $dwPreshutdownTimeout) Case $SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO ; update required Privileges Local $aRequiredPrivileges = $aInfo[$dwInfoLevel] Local $iRequiredPrivilegesCount = UBound($aRequiredPrivileges) Local $serviceRequiredPrivilegesInfo = DllStructCreate("PTR pmszRequiredPrivileges") Local $lpInfo = DllStructGetPtr($serviceRequiredPrivilegesInfo) Local $spmszRequiredPrivilegesDefinition = "" For $i = 0 to $iRequiredPrivilegesCount-1 $spmszRequiredPrivilegesDefinition &= "wchar[" & (StringLen($aRequiredPrivileges[$i]) + 1) & "];" Next $spmszRequiredPrivilegesDefinition &= "wchar" Local $pmszRequiredPrivileges = DllStructCreate($spmszRequiredPrivilegesDefinition) For $i = 0 to $iRequiredPrivilegesCount-1 DllStructSetData($pmszRequiredPrivileges, $i+1, $aRequiredPrivileges[$i]) Next DllStructSetData($serviceRequiredPrivilegesInfo, "pmszRequiredPrivileges", DllStructGetPtr($pmszRequiredPrivileges)) Case $SERVICE_CONFIG_SERVICE_SID_INFO ; update SID info Local $dwServiceSidType = $aInfo[$dwInfoLevel] Local $serviceSidInfo = DllStructCreate("DWORD dwServiceSidType") Local $lpInfo = DllStructGetPtr($serviceSidInfo) DllStructSetData($serviceSidInfo, "dwServiceSidType", $dwServiceSidType) Case $SERVICE_CONFIG_TRIGGER_INFO ; update triggers Local $aTriggerInfo = $aInfo[$dwInfoLevel] Local $serviceTriggerInfo = DllStructCreate("DWORD cTriggers;PTR pTriggers;PTR pReserved") Local $lpInfo = DllStructGetPtr($serviceTriggerInfo) Local $cTriggers = $aTriggerInfo[0] Local $aTriggers = $aTriggerInfo[1] Local $pReserved = Null Local $tagServiceTriggerItem = "DWORD dwTriggerType;DWORD dwAction;PTR pTriggerSubType;DWORD cDataItems;PTR pDataItems" Local $itServiceTriggerItemSize = DllStructGetSize(DllStructCreate($tagServiceTriggerItem)) Local $tArrayServiceTrigger = DllStructCreate("byte[" & ($cTriggers * $itServiceTriggerItemSize) & "]") Local $pTriggers If $cTriggers > 0 Then ; Find max # of data items assigned to any of the triggers ; Note: In order to simplify the code related to array ; handling, the minimum size max will be set to 1 ; even if it is 0 in reality. Local $cDataItemsMax = 1 For $i = 0 to $cTriggers-1 Local $aTrigger = $aTriggers[$i] Local $cDataItems = $aTrigger[3] $cDataItemsMax = _Max($cDataItemsMax, $cDataItems) Next ; Declare arrays used for holding various Struct objects. ; Note: When DllStructCreate allocates memory for holding a ; Struct object's data, the output of DllStructCreate ; can be assigned to a variable. If that variable is ; subsequently reassigned, such as during a for..next ; loop, the memory where the previously referenced Struct ; object is stored is released. This means that any ; pointer to that memory location is pointing to a ; location that is no longer protected from reuse. ; Originally, due to the use of loops to iterate over ; the triggers and trigger data items, memory that ; contained Structs was being freed before the code ; that referenced those memory locations was ready. This ; lead in some cases to that memory being overwritten ; resulting in incorrect information being used. Local $tGUID[$cTriggers], $tArrayServiceTriggerSpecificDataItem[$cTriggers], $atDataItemData[$cTriggers][$cDataItemsMax] For $i = 0 to $cTriggers-1 Local $aTrigger = $aTriggers[$i] Local $dwTriggerType = $aTrigger[0] Local $dwAction = $aTrigger[1] Local $sGUID = $aTrigger[2] Local $cDataItems = $aTrigger[3] Local $aDataItems = $aTrigger[4] $tGUID[$i] = _WinAPI_GUIDFromString($sGUID) Local $pTriggerSubType = DllStructGetPtr($tGUID[$i]) Local $tagServiceTriggerSpecificDataItem = "DWORD dwDataType;DWORD cbData;PTR pData" Local $itServiceTriggerSpecificDataItem = DllStructGetSize(DllStructCreate($tagServiceTriggerSpecificDataItem)) $tArrayServiceTriggerSpecificDataItem[$i] = DllStructCreate("byte[" & ($cDataItems * $itServiceTriggerSpecificDataItem) & "]") Local $pDataItems If $cDataItems > 0 Then For $j = 0 to $cDataItems-1 Local $aDataItem = $aDataItems[$j] Local $dwDataType = $aDataItem[0] Local $cbData = $aDataItem[1] Local $sData = $aDataItem[2] Switch $dwDataType Case 1 ; SERVICE_TRIGGER_DATA_TYPE_BINARY $atDataItemData[$i][$j] = DllStructCreate("byte["&$cbData&"]") Local $aData = StringSplit($sData, " ") For $k = 1 to $cbData DllStructSetData($atDataItemData[$i][$j], 1, Dec($aData[$k]), $k) Next Case 2 ; SERVICE_TRIGGER_DATA_TYPE_STRING $atDataItemData[$i][$j] = DllStructCreate("wchar["&($cbData/2)&"];wchar") DllStructSetData($atDataItemData[$i][$j], 1, $sData) Case 3 ; SERVICE_TRIGGER_DATA_TYPE_LEVEL $atDataItemData[$i][$j] = DllStructCreate("byte") DllStructSetData($atDataItemData[$i][$j], 1, $sData) Case 4, 5 ; SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY, SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL $atDataItemData[$i][$j] = DllStructCreate("UINT64") DllStructSetData($atDataItemData[$i][$j], 1, $sData) EndSwitch Local $pData = DllStructGetPtr($atDataItemData[$i][$j]) Local $tServiceTriggerSpecificDataItem = DllStructCreate($tagServiceTriggerSpecificDataItem, DllStructGetPtr($tArrayServiceTriggerSpecificDataItem[$i]) + ($j * $itServiceTriggerSpecificDataItem)) DllStructSetData($tServiceTriggerSpecificDataItem, "dwDataType", $dwDataType) DllStructSetData($tServiceTriggerSpecificDataItem, "cbData", $cbData) DllStructSetData($tServiceTriggerSpecificDataItem, "pData", $pData) Next $pDataItems = DllStructGetPtr($tArrayServiceTriggerSpecificDataItem[$i]) Else $pDataItems = Null EndIf Local $tServiceTriggerItem = DllStructCreate($tagServiceTriggerItem, DllStructGetPtr($tArrayServiceTrigger) + ($i * $itServiceTriggerItemSize)) DllStructSetData($tServiceTriggerItem, "dwTriggerType", $dwTriggerType) DllStructSetData($tServiceTriggerItem, "dwAction", $dwAction) DllStructSetData($tServiceTriggerItem, "pTriggerSubType", $pTriggerSubType) DllStructSetData($tServiceTriggerItem, "cDataItems", $cDataItems) DllStructSetData($tServiceTriggerItem, "pDataItems", $pDataItems) Next $pTriggers = DllStructGetPtr($tArrayServiceTrigger) Else $pTriggers = Null EndIf DllStructSetData($serviceTriggerInfo, "cTriggers", $cTriggers) DllStructSetData($serviceTriggerInfo, "pTriggers", $pTriggers) DllStructSetData($serviceTriggerInfo, "pReserved", $pReserved) Case $SERVICE_CONFIG_LAUNCH_PROTECTED ; update launch protected info ; Note: This seems to be only changable once otherwise an error will occur. ; Also, if this is set to anything but 0, no further changes will be possible. ; Reverting this setting must be done manually via Regedit by editing ; LaunchProtected under the ; HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SheltSrv2 key and ; setting it to 0 and then rebooting. Local $dwLaunchProtected = $aInfo[$dwInfoLevel] Local $serviceLaunchProtectedInfo = DllStructCreate("DWORD dwLaunchProtected") Local $lpInfo = DllStructGetPtr($serviceLaunchProtectedInfo) DllStructSetData($serviceLaunchProtectedInfo, "dwLaunchProtected", $dwLaunchProtected) EndSwitch ChangeServiceConfig2($hService, $dwInfoLevel, $lpInfo) Next CloseServiceHandle($hService) CloseServiceHandle($hSC) EndFunc ;==>_Service_ChangeConfig2 ; #FUNCTION# ======================================================================================================================================================= ; Name...........: _Service_QueryConfig2 ; Description ...: Retrieves the optional configuration parameters of the specified service. ; Syntax.........: _Service_QueryConfig2($sServiceName, $tQC [, $sComputerName]) ; Parameters ....: $sServiceName - Name of the service. ; $sComputerName - [Optional] The name of the target computer. The local computer is default. ; Requirement(s).: None. ; Return values .: Success - Returns array of configuration settings indexed by InfoLevel. ; Failure - 0 ; Sets @error ; Author ........: chinadoug ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ================================================================================================================================================================== Func _Service_QueryConfig2($sServiceName, $sComputerName = "") Local $hSC, $hService, $avQA, $tQB, $avQB, $iQE, $tQC $hSC = OpenSCManager($sComputerName, $SC_MANAGER_CONNECT) $hService = OpenService($hSC, $sServiceName, $SERVICE_QUERY_CONFIG) Local $aInfoLevels[] = [$SERVICE_CONFIG_DELAYED_AUTO_START_INFO, _ $SERVICE_CONFIG_DESCRIPTION, _ $SERVICE_CONFIG_FAILURE_ACTIONS, _ $SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, _ $SERVICE_CONFIG_PREFERRED_NODE, _ $SERVICE_CONFIG_PRESHUTDOWN_INFO, _ $SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO, _ $SERVICE_CONFIG_SERVICE_SID_INFO, _ $SERVICE_CONFIG_TRIGGER_INFO, _ $SERVICE_CONFIG_LAUNCH_PROTECTED] Local $aInfo[13] For $i = 0 to UBound($aInfoLevels)-1 Local $iInfoLevel = $aInfoLevels[$i] ; Determine needed size of the struct in bytes $avQA = QueryServiceConfig2($hService, $iInfoLevel, 0, 0) ; Get Service data $tQB = DllStructCreate("ubyte[" & $avQA[5] & "]") $avQB = QueryServiceConfig2($hService, $iInfoLevel, DllStructGetPtr($tQB), DllStructGetSize($tQB)) Local $lpInfo = $avQB[3] ; Get last error If $avQB[0] = 0 Then $iQE = _WinAPI_GetLastError() ; Decode the ubyte structure Switch $iInfoLevel Case $SERVICE_CONFIG_DELAYED_AUTO_START_INFO ; get delayed auto start information ; Note: This setting is ignored unless Startup Type is set to Automatic. Local $serviceDelayedAutoStartInfo = DllStructCreate("INT fDelayedAutostart", $lpInfo) Local $fDelayedAutostart = DllStructGetData($serviceDelayedAutoStartInfo, "fDelayedAutostart") $aInfo[$SERVICE_CONFIG_DELAYED_AUTO_START_INFO] = $fDelayedAutostart Case $SERVICE_CONFIG_DESCRIPTION ; get service description (assumes length is less than or equal to 2048 characters) Local $serviceDescription = DllStructCreate("PTR lpDescription", $lpInfo) Local $lpDescription = DllStructGetData($serviceDescription, "lpDescription") Local $tDescription = DllStructCreate("wchar[2048]", $lpDescription) Local $sDescription = DllStructGetData($tDescription, 1) $aInfo[$SERVICE_CONFIG_DESCRIPTION] = $sDescription Case $SERVICE_CONFIG_FAILURE_ACTIONS ; get failure actions Local $aFailureActions[5] Local $serviceFailureActions = DllStructCreate("DWORD dwResetPeriod;PTR lpRebootMsg;PTR lpCommand;DWORD cActions;PTR lpsaActions", $lpInfo) $aFailureActions[0] = DllStructGetData($serviceFailureActions, "dwResetPeriod") Local $lpRebootMsg = DllStructGetData($serviceFailureActions, "lpRebootMsg") Local $tRebootMsg = DllStructCreate("wchar[2048]", $lpRebootMsg) $aFailureActions[1] = DllStructGetData($tRebootMsg, 1) Local $lpCommand = DllStructGetData($serviceFailureActions, "lpCommand") Local $tCommand = DllStructCreate("wchar[2048]", $lpCommand) $aFailureActions[2] = DllStructGetData($tCommand, 1) Local $cActions = DllStructGetData($serviceFailureActions, "cActions") $aFailureActions[3] = $cActions Local $lpsaActions = DllStructGetData($serviceFailureActions, "lpsaActions") Local $tagSC_ACTION = "INT Type;DWORD Delay" Local $itSC_ACTIONSize = DllStructGetSize(DllStructCreate($tagSC_ACTION)) If $cActions > 0 Then Local $aActions[$cActions] For $j = 0 to $cActions-1 Local $tSC_ACTION = DllStructCreate($tagSC_ACTION, $lpsaActions + ($j * $itSC_ACTIONSize)) Local $aAction[2] = [DllStructGetData($tSC_ACTION, "Type"), DllStructGetData($tSC_ACTION, "Delay")] $aActions[$j] = $aAction Next $aFailureActions[4] = $aActions Else $aFailureActions[4] = Null EndIf $aInfo[$SERVICE_CONFIG_FAILURE_ACTIONS] = $aFailureActions Case $SERVICE_CONFIG_FAILURE_ACTIONS_FLAG ; get failure actions flag Local $serviceFailureActionsFlag = DllStructCreate("INT fFailureActionsOnNonCrashFailures", $lpInfo) Local $fFailureActionsOnNonCrashFailures = DllStructGetData($serviceFailureActionsFlag, "fFailureActionsOnNonCrashFailures") $aInfo[$SERVICE_CONFIG_FAILURE_ACTIONS_FLAG] = $fFailureActionsOnNonCrashFailures Case $SERVICE_CONFIG_PREFERRED_NODE ; get preferred node Local $servicePreferredNodeInfo = DllStructCreate("USHORT usPreferredNode;BOOLEAN fDelete", $lpInfo) Local $usPreferredNode = DllStructGetData($servicePreferredNodeInfo, "usPreferredNode") Local $fDelete = False Local $aPreferredNodeInfo[2] = [$usPreferredNode, $fDelete] $aInfo[$SERVICE_CONFIG_PREFERRED_NODE] = $aPreferredNodeInfo Case $SERVICE_CONFIG_PRESHUTDOWN_INFO ; get preshutdown info Local $servicePreshutdownInfo = DllStructCreate("DWORD dwPreshutdownTimeout", $lpInfo) Local $dwPreshutdownTimeout = DllStructGetData($servicePreshutdownInfo, "dwPreshutdownTimeout") $aInfo[$SERVICE_CONFIG_PRESHUTDOWN_INFO] = $dwPreshutdownTimeout Case $SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO ; get required Privileges Local $serviceRequiredPrivilegesInfo = DllStructCreate("PTR pmszRequiredPrivileges", $lpInfo) Local $pmszRequiredPrivileges = DllStructGetData($serviceRequiredPrivilegesInfo, "pmszRequiredPrivileges") Local $sRequiredPrivileges = "" While(True) Local $tmszRequiredPrivileges = DllStructCreate("wchar[2048]", $pmszRequiredPrivileges + $iOffset) If DllStructGetSize($tmszRequiredPrivileges) = 0 Then ExitLoop Local $sRequiredPrivilege = DllStructGetData($tmszRequiredPrivileges, 1) If $sRequiredPrivilege == "" Then ExitLoop $sRequiredPrivileges &= $sRequiredPrivilege & ";" $iOffset += 2 * (StringLen($sRequiredPrivilege) + 1) WEnd If $sRequiredPrivileges == "" Then Local $aRequiredPrivileges = Null Else $sRequiredPrivileges = StringTrimRight($sRequiredPrivileges,1) Local $aRequiredPrivileges = StringSplit($sRequiredPrivileges, ";", $STR_NOCOUNT) EndIf $aInfo[$SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO] = $aRequiredPrivileges Case $SERVICE_CONFIG_SERVICE_SID_INFO ; get SID info Local $serviceSidInfo = DllStructCreate("DWORD dwServiceSidType", $lpInfo) Local $dwServiceSidType = DllStructGetData($serviceSidInfo, "dwServiceSidType") $aInfo[$SERVICE_CONFIG_SERVICE_SID_INFO] = $dwServiceSidType Case $SERVICE_CONFIG_TRIGGER_INFO ; get trigger information Local $serviceTriggerInfo = DllStructCreate("DWORD cTriggers;PTR pTriggers;PTR pReserved", $lpInfo) Local $cTriggers = DllStructGetData($serviceTriggerInfo, "cTriggers") Local $pTriggers = DllStructGetData($serviceTriggerInfo, "pTriggers") Local $tagServiceTriggerItem = "DWORD dwTriggerType;DWORD dwAction;PTR pTriggerSubType;DWORD cDataItems;PTR pDataItems" Local $itServiceTriggerItemSize = DllStructGetSize(DllStructCreate($tagServiceTriggerItem)) If $cTriggers > 0 Then Local $aTriggers[$cTriggers] For $j = 0 to $cTriggers-1 Local $aTrigger[5] Local $tServiceTriggerItem = DllStructCreate($tagServiceTriggerItem, $pTriggers + ($j * $itServiceTriggerItemSize)) Local $dwTriggerType = DllStructGetData($tServiceTriggerItem, "dwTriggerType") Local $dwAction = DllStructGetData($tServiceTriggerItem, "dwAction") Local $pTriggerSubType = DllStructGetData($tServiceTriggerItem, "pTriggerSubType") Local $cDataItems = DllStructGetData($tServiceTriggerItem, "cDataItems") Local $pDataItems = DllStructGetData($tServiceTriggerItem, "pDataItems") $aTrigger[0] = $dwTriggerType $aTrigger[1] = $dwAction Local $tGUID = DllStructCreate("ULONG;USHORT;USHORT;BYTE[8]",$pTriggerSubType) Local $sGUID = _WinAPI_StringFromGUID($tGUID) $aTrigger[2] = $sGUID $aTrigger[3] = $cDataItems Local $tagServiceTriggerSpecificDataItem = "DWORD dwDataType;DWORD cbData;PTR pData" Local $itServiceTriggerSpecificDataItem = DllStructGetSize(DllStructCreate($tagServiceTriggerSpecificDataItem)) If $cDataItems > 0 Then Local $aTriggerSpecificDataItems[$cDataItems] For $k = 0 to $cDataItems-1 Local $aTriggerSpecificDataItem[3] Local $tServiceTriggerSpecificDataItem = DllStructCreate($tagServiceTriggerSpecificDataItem, $pDataItems + ($k * $itServiceTriggerSpecificDataItem)) Local $dwDataType = DllStructGetData($tServiceTriggerSpecificDataItem, "dwDataType") Local $cbData = DllStructGetData($tServiceTriggerSpecificDataItem, "cbData") Local $pData = DllStructGetData($tServiceTriggerSpecificDataItem, "pData") $aTriggerSpecificDataItem[0] = $dwDataType $aTriggerSpecificDataItem[1] = $cbData Switch $dwDataType Case 1 ; SERVICE_TRIGGER_DATA_TYPE_BINARY Local $tData = DllStructCreate("BYTE["&$cbData&"]", $pData) Local $aDataHex[$cbData] For $l = 1 to $cbData $aDataHex[$l-1] = Hex(DllStructGetData($tData,1,$l), 2) Next Local $sData = _ArrayToString($aDataHex," ") Case 2 ; SERVICE_TRIGGER_DATA_TYPE_STRING Local $tData = DllStructCreate("WCHAR["&($cbData/2)&"]", $pData) Local $sData = DllStructGetData($tData,1) Case 3 ; SERVICE_TRIGGER_DATA_TYPE_LEVEL Local $tData = DllStructCreate("BYTE", $pData) Local $iData = DllStructGetData($tData,1) Local $sData = $iData Case 4, 5 ; SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY, SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL Local $tData = DllStructCreate("UINT64", $pData) Local $iData = DllStructGetData($tData,1) Local $sData = $iData EndSwitch $aTriggerSpecificDataItem[2] = $sData $aTriggerSpecificDataItems[$k] = $aTriggerSpecificDataItem Next Else Local $aTriggerSpecificDataItems = Null EndIf $aTrigger[4] = $aTriggerSpecificDataItems $aTriggers[$j] = $aTrigger Next Else Local $aTriggers = Null EndIf Local $aTriggerInfo[2] = [$cTriggers, $aTriggers] $aInfo[$SERVICE_CONFIG_TRIGGER_INFO] = $aTriggerInfo Case $SERVICE_CONFIG_LAUNCH_PROTECTED ; get launch protected info Local $serviceLaunchProtectedInfo = DllStructCreate("DWORD dwLaunchProtected", $lpInfo) Local $dwLaunchProtected = DllStructGetData($serviceLaunchProtectedInfo, "dwLaunchProtected") $aInfo[$SERVICE_CONFIG_LAUNCH_PROTECTED] = $dwLaunchProtected EndSwitch Next CloseServiceHandle($hService) CloseServiceHandle($hSC) Return SetError($iQE, 0, $aInfo) EndFunc ;==>_Service_QueryConfig2 Func ChangeServiceConfig2($hService, $dwInfoLevel, $lpInfo) Local $avCSC2 = DllCall($hAdvapi32_DLL, "int", "ChangeServiceConfig2W", _ "ptr", $hService, _ "dword", $dwInfoLevel, _ "ptr", $lpInfo) If @error Then Return SetError(@error, 0, 0) Return $avCSC2[0] EndFunc ;==>ChangeServiceConfig2 Func QueryServiceConfig2($hService, $iInfoLevel, $pBuffer, $iBufSize) Local $avQSC2 = DllCall($hAdvapi32_DLL, "int", "QueryServiceConfig2W", _ "ptr", $hService, _ "dword", $iInfoLevel, _ "ptr", $pBuffer, _ "dword", $iBufSize, _ "dword*", 0) Return $avQSC2 EndFunc ;==>QueryServiceConfig2
    1 point
  8. _Excel_RangeWrite Not Working With Large Dataset ... Well, that's the thing. I don't think that excel is a database. And abusing it is just wrong. But, is hard to find a programmer in an office environment so people work with what they have, but eventually they are going to need to code something to handle large datasets. And all this excel stuff, ...you are lucky to not run into the file getting corrupted. I know that am not helping but is something that I feel should be said.
    1 point
  9. Did you compile as 64 bit and use #RequireAdmin? Example: #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Run("PowerShell.exe -noexit Get-RDUserSession")
    1 point
×
×
  • Create New...