Jump to content

Help required with SecurityEx.au3


ChetzB
 Share

Recommended Posts

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 by ChetzB
Link to comment
Share on other sites

Looks like you are missing an & before $serviceExists

ConsoleWrite('Service: "' & $displayName & '" exists = "' $serviceExists & '"' & @CRLF)

Should be

ConsoleWrite('Service: "' & $displayName & '" exists = "' & $serviceExists & '"' & @CRLF)

 

Edited by spudw2k
Link to comment
Share on other sites

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

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.

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

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 by ChetzB
Output correction.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...