ChetzB Posted September 28, 2023 Share Posted September 28, 2023 (edited) Hello, It's been a while since I've used AutoIT and I was updating a script where I've used "SecurityEx.au3". I initially ran into a problem which was found on this post: Using Dotaznik's comments I replaced the $RIGHTS_DELETE with $STANDARD_RIGHTS_DELETE and this solved one issue, however I'm getting another issue which I've replicated away from my main script in a test script seen below: #include <SecurityEx.au3> #include <Services.au3> Local $serviceName = 'wuauserv' Local $displayName = 'Windows Update' Local $serviceExists = _Service_Exists($serviceName) ConsoleWrite('Service: "' & $displayName & '" exists = "' $serviceExists & '"' & @CRLF) Below is the error I get when I try to run the script or when I try to compile it: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /Prod /AU3check /in "C:\TEST\DevAutoIT_ServiceTesting.au3" +>18:04:24 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0 Keyboard:00000809 OS:WIN_11/ CPU:X64 OS:X64 Environment(Language:0809) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper >Running AU3Check (3.3.16.1) from:C:\Program Files (x86)\AutoIt3 input:C:\TEST\DevAutoIT_ServiceTesting.au3 "C:\TEST\SecurityEx.au3"(58,42) : warning: $TOKEN_ADJUST_PRIVILEGES: possibly used before declaration. "dword", BitOR($TOKEN_ADJUST_PRIVILEGES, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\TEST\SecurityEx.au3"(58,56) : warning: $TOKEN_QUERY: possibly used before declaration. "dword", BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\TEST\DevAutoIT_ServiceTesting.au3"(7,59) : error: syntax error ConsoleWrite('Service: "' & $displayName & '" exists = "' $serviceExists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\TEST\DevAutoIT_ServiceTesting.au3 - 1 error(s), 2 warning(s) !>18:04:24 AU3Check ended. Press F4 to jump to next error.rc:2 +>18:04:24 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.667 I've gone through Engine's post below on the SecurityEx.au3 and Services.au3 files in case those were updated since I last used this script but those seem identical, minus the changes made based on Dotaznik's comments on the linked post. I'm clearly not understanding the issue but I am also struggling with how to correct the fault. Any help would be greatly appreciated. 🙏 Edited September 28, 2023 by ChetzB Link to comment Share on other sites More sharing options...
spudw2k Posted September 28, 2023 Share Posted September 28, 2023 (edited) Looks like you are missing an & before $serviceExists ConsoleWrite('Service: "' & $displayName & '" exists = "' $serviceExists & '"' & @CRLF) Should be ConsoleWrite('Service: "' & $displayName & '" exists = "' & $serviceExists & '"' & @CRLF) Edited September 28, 2023 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ChetzB Posted September 29, 2023 Author Share Posted September 29, 2023 Thank you for that and sorry for missing a simple issue. After correcting the missing "&", this still yields the same problem. #include <SecurityEx.au3> #include <Services.au3> $serviceName = 'wuauserv' $displayName = 'Windows Update' $serviceExists = _Service_Exists($serviceName) ConsoleWrite('Service: "' & $displayName & '" exists = "' & $serviceExists & '"' & @CRLF) This the script output error: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\TEST\DevAutoIT_ServiceTesting2.au3" /UserParams +>08:32:38 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0 Keyboard:00000809 OS:WIN_11/ CPU:X64 OS:X64 Environment(Language:0809) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper >Running AU3Check (3.3.16.1) from:C:\Program Files (x86)\AutoIt3 input:C:\TEST\DevAutoIT_ServiceTesting2.au3 "C:\TEST\SecurityEx.au3"(58,42) : warning: $TOKEN_ADJUST_PRIVILEGES: possibly used before declaration. "dword", BitOR($TOKEN_ADJUST_PRIVILEGES, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\TEST\SecurityEx.au3"(58,56) : warning: $TOKEN_QUERY: possibly used before declaration. "dword", BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\TEST\DevAutoIT_ServiceTesting2.au3 - 0 error(s), 2 warning(s) ->08:32:38 AU3Check ended. Press F4 to jump to next error.rc:1 >Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\TEST\DevAutoIT_ServiceTesting2.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Service: "Windows Update" exists = "1" +>08:32:38 AutoIt3.exe ended.rc:0 +>08:32:38 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6782 I've attached both includes that I am using as well. I know from the error it's that these variables are being called before being set, but I'm just not use if it's similar to my previous error where they have changed elsewhere or no longer being declared. SecurityEx.au3 Services.au3 Link to comment Share on other sites More sharing options...
water Posted September 29, 2023 Share Posted September 29, 2023 When you search the forum for $TOKEN_ADJUST_PRIVILEGES you will find the following thread. There the WinAPIProc.au3 gets included. Can you give this a try? I can't test at the moment. ChetzB 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
ChetzB Posted September 29, 2023 Author Share Posted September 29, 2023 (edited) Thanks @water! I had a read over the linked thread and tried the additional include (WinAPIProc.au3), but still no dice. I did comment out my include of "SecurityEx.au3" and tried running the script which seems to work now. I was certain that this include was required in the past, so just very confused. ;~ #include <SecurityEx.au3> #include <Services.au3> ;~ #include <WinAPIProc.au3> $serviceName = 'wuauserv' $displayName = 'Windows Update' $serviceExists = _Service_Exists($serviceName) ConsoleWrite('Service: "' & $displayName & '" exists = "' & $serviceExists & '"' & @CRLF) Output now seems to work as expected: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\TEMP\DevAutoIT_ServiceTesting2.au3" /UserParams +>09:53:33 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0 Keyboard:00000809 OS:WIN_11/ CPU:X64 OS:X64 Environment(Language:0809) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper >Running AU3Check (3.3.16.1) from:C:\Program Files (x86)\AutoIt3 input:C:\TEMP\DevAutoIT_ServiceTesting2.au3 +>09:53:33 AU3Check ended.rc:0 >Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\TEMP\DevAutoIT_ServiceTesting2.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Service: "Windows Update" exists = "1" +>09:53:33 AutoIt3.exe ended.rc:0 +>09:53:33 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6766 Edited September 29, 2023 by ChetzB Output correction. 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