Jump to content

Recommended Posts

Posted

A UDF is simply a piece of code which is included into the script where the #include statement is defined (main script).

If the main script has #RequireAdmin this is true for the UDF too.

You really have to compile separate EXE files to run them with different permissions!

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

 

Posted

Not that I know off :oops:

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

 

Posted

Another idea:

Write two scripts:One runs with user privileges and does all the llep stuff etc. and the second script runs with admin privileges and does the 4 functions you require. You pass a parameter to this script which tells what function to execute.

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

 

Posted (edited)

Another idea:

Write two scripts:One runs with user privileges and does all the llep stuff etc. and the second script runs with admin privileges and does the 4 functions you require. You pass a parameter to this script which tells what function to execute.

Is not the same i have do with UDF?

The UDF (<Test.au3>) do operation with admin privilege

#include-once
#RequireAdmin

Func _Test($handle)
MsgBox(0,0,$handle)
EndFunc ;==>_Test

The main script, without admin, call the simply function and _Test with admin

#include <Test.au3>

MsgBox(0,0,"Is admin?") ; Not admin
_Test("asd") ; admin

There is another way to do that? Because not work like expeted, the script start like admin also for the simply MsgBox

Please, provide an example script, so i cant test it with mine :oops:

Edited by johnmcloud
Posted

I will provide a sample as soon as I find some spare minutes.

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

 

Posted

Test.au3

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$sTitle = "Test Script"
If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!")
If $CmdLine[1] = "/?" Then ConsoleWrite("Help follows here ..." & @CRLF)
If $CmdLine[1] = "/dir" Then RunWait("test2.exe /dir C:\temp\*.exe")
ConsoleWrite(@ScriptName & " finished!")

Test2.au3

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Change2CUI=y
; #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Requireadmin
$sTitle = "Test2 Script"
If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!")
If $CmdLine[1] = "/dir" Then
    RunWait(@ComSpec & " /c " & 'Dir ' & $CmdLine[2])
EndIf
ConsoleWrite(@ScriptName & " finished!")
MsgBox(16, @ScriptName, "Wait ...")

Place both scripts into C:\temp and compile them.

Open a CMD window and enter "CD /d C:\temp".

Enter "test /?" and you will get the "help" output in the opened DOS console

Enter "test /dir" and the command "Dir C:\temp\*.exe" will be executed as administrator and the result will be displayed in a separate window.

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

 

  • 1 year later...
Posted (edited)

I've solved this by using this:

AutoIT

If $CmdLine[0]=1 Then Exit
If $CmdLine[0]=0 Then Exit
If $CmdLine[1] = "parametername=" Then 
    If $CmdLine[2] <> "" Then $ip = $CmdLine[2]
EndIf
If $CmdLine[0]=2 Then Exit
If $CmdLine[3] = "parametername2=" Then
    If $CmdLine[4] <> "" Then $name = $CmdLine[4]
EndIf

So I can use more parameters and correct parameters. By using this, I can choose what parameters I want to use. 

CMD

myscript.exe parametername= hello parametername2= nothello

So this is how I do with CMD. If you want to be able to choose your parameters, just to this;

AutoIT - Total

Full script, with notes. 

; If the first parameter exists
If $CmdLine[0]=1 Then Exit

; If no parameters has been entered
If $CmdLine[0]=0 Then Exit

; Checking parameter1
If $CmdLine[1] = "parametername=" Then
        ; if the parameter contains anything
    If $CmdLine[2] <> "" Then msgbox(0, "Parametername1", "You did it! nr1")
EndIf

; Checking parameter2
If $CmdLine[1] = "parametername2=" Then
        ; if the parameter contains anything
    If $CmdLine[2] <> "" Then msgbox(0, "Parametername2", "You did it! nr2")
EndIf

; If a parameter2 has been entered.
If $CmdLine[0]=2 Then Exit

; Checking parameter 1
If $CmdLine[3] = "paramentername=" Then
        ; if the parameter contains anything
    If $CmdLine[4] <> "" Then msgbox(0, "Parametername1", "You did it! nr1")
EndIf

; Checking parameter 2
If $CmdLine[3] = "parametername2=" Then
        ; if the parameter contains anything
    If $CmdLine[4] <> "" Then msgbox(0, "Parametername2", "You did it! nr2")
EndIf
Edited by Fredricz

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...