Jump to content

Running file as admin in Win 7 vs XP


koons
 Share

Recommended Posts

No, just copy/paste it in a new file and then compile it.

 

That's what I did.  But don't mind me.  I simply forgot to save the .au3 before I tried compiling.  I never claimed to be good at this.   ;)

So I got that elevate.exe created and now when I run the other .exe I keep getting an "Unknown function name" error.  I did remove the _RunAsElevate function you had suggested in a previous post, but I'm pretty sure that wouldn't have any affect on it.

#pragma compile(AutoItExecuteAllowed, True)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <array.au3>
#include <GuiListView.au3>


#Region ### START Koda GUI section ### Form=c:\documents and settings\andrew.mclean\my documents\scripts\idsupdater\idsupdater.kxf
$IDSUpdaterForm = GUICreate("IDS Updater", 633, 447, 1584, 161)
    GUISetBkColor(0xA6CAF0)
$IDSUpdaterTitle = GUICtrlCreateLabel("IDS Updater 2.0", 179, 24, 275, 49)
    GUICtrlSetFont(-1, 30, 800, 4, "Garamond")
    GUICtrlSetColor(-1, 0x000000)
$Directions1 = GUICtrlCreateLabel("Please select the update you wish to install from the below list", 85, 104, 463, 25)
    GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman")
$Directions2 = GUICtrlCreateLabel(" and hit the Update button.", 217, 136, 203, 25)
    GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman")
    GUISetState(@SW_SHOW)
$AvailableUpdatesList = GUICtrlCreateListView("", 118, 165, 401, 160)
    GUICtrlSetFont(-1, 10, 400, 0, "Times New Roman")
    GUICtrlSetCursor (-1, 0)
    _GUICtrlListView_AddColumn($AvailableUpdatesList,"Available updates",397)
$FileList=_FileListToArray("\\domain.com\apps\IDS","*.exe")
    If @error=1 Then
        MsgBox(0,"","No folders found.")
        Exit
    EndIf
    If @error=4 Then
        MsgBox(0,"","No files found.")
        Exit
    EndIf
    Dim $a_lv_array[$FileList[0]][1]
    For $i = 1 To $FileList[0]
        $a_lv_array[$i - 1][0] = $FileList[$i]
    Next
    _GUICtrlListView_AddArray($AvailableUpdatesList,$a_lv_array)
$UpdateButton = GUICtrlCreateButton("Update", 120, 360, 153, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
$CancelButton = GUICtrlCreateButton("Cancel", 440, 360, 81, 41, $WS_GROUP)
    GUICtrlSetFont(-1, 12, 800, 0, "Times New Roman")
$Directions3 = GUICtrlCreateLabel("After clicking Update, there will be a delay while file is downloading.", 110, 410, 463, 25)
    GUICtrlSetFont(-1, 9, 400, 0, "Times New Roman")
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    WinMove("IDS Updater","",100,100)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $CancelButton
            Exit
        Case $UpdateButton
            Local $sUserName = "admin"
            Local $sDomainName = "domain.com"
            Local $sPassword = "secret"
            Local $sSelected = _GUICtrlListView_GetItemText($AvailableUpdatesList,number(_GUICtrlListView_GetSelectedIndices($AvailableUpdatesList)))
            If Not IsAdmin() Then
                RunAs($sUsername, $sDomainName, $sPassword, 0, elevate.exe "\\domain.com\apps\IDS\" & $sSelected, @WindowsDir, "")
            Else
                MsgBox(0,"Silly goose.","You're an admin.  You don't need to run this.")
            EndIf
            Sleep(200)
            Exit
    EndSwitch
 WEnd
Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Can you also post the full error message you received?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Compile your script with these at the top:

#Region
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so
#EndRegion

 

This will create a .au3 stripped file like such: example_stripped.au3

You should be able to go and see what is on line 10104 in the stripped script.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

The working directory. Should be with your .au3 file and your .exe compiled file.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

I just compiled with these directives as mentioned above. The file I used was saved on my desktop named ex.au3

#Region
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so
#EndRegion

As you can see after hitting F7 in the SciTE editor (compile) I got this:

post-86910-0-57443800-1410877871.png

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

There is an error in this line :

RunAs($sUsername, $sDomainName, $sPassword, 0, elevate.exe "\\domain.com\apps\IDS\" & $sSelected, @WindowsDir, "")

it must be :

RunAs($sUsername, $sDomainName, $sPassword, 0, "elevate.exe \\domain.com\apps\IDS\" & $sSelected, @WindowsDir)
Link to comment
Share on other sites

you got a way bro.

You can cript your password in your script to make it hidden so you will be able to use admin right for you script without show it to all of your users ...

the only weird thing is: it take long time to code and it s a bit complicated... (For ppls like me becose i am low skilled)

i got exemple of script for you if you are interesting in this but dont got time to code for you unfortunalty :(

i dit an auto login script secured by cripted stored password and i am pretty sure you can do same with your script.

 

EDIT: But i am open for anyhelp. (if you like that idea)

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

You might like to take a look at http://sf.net/projects/softwarepolicy

This is basically a replacement for UAC, and works on the principle that:

  • The user is a proper administrator
  • LAN connections are never lost due to permissions changes
  • All programs can be run with full rights except those specified as 'high risk' eg browsers
  • Restrictions are set on the disk locations programs can be run from

Two major advantages are overcoming the loss of LAN connections caused by UAC, which is extremely problematic for business users, and that it is not so easy to spoof the user into robotically clicking 'Yes' to a malicious elevation prompt.  

For software installation work, the protection can be turned off for a specified interval of time during which you won't be bothered again by prompts. You can even reboot without the status changing. At the end of the time limit the protection automatically turns itself back on, in case you forgot.

Obviously not so appropriate if you are distributing your script, but for inhouse use it's a very good solution to keeping security tight without the problems raised by UAC.

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