Jump to content

Windows 7 Elevated app is unable to open DLL or INI


Recommended Posts

Hi all,

have been using the following code in Vista & Prerelease win7 machines, and it worked well.

#Region IsAdmin
If Not IsAdmin() Then
    If _IsAdministrator() Then
        If @Compiled Then
            TraySetState(2)
            ShellExecuteWait(@AutoItExe, "", "", "runas")
            ;           MsgBox(64, "", "IsAdmin() = " & IsAdmin())
            Exit
        Else
            TraySetState(2)
            ShellExecuteWait(@AutoItExe, ' /AutoIt3ExecuteScript "' & @ScriptFullPath & '"', "", "runas")
            ;           MsgBox(64, "", "IsAdmin() = " & IsAdmin())
            Exit
        EndIf
    EndIf
EndIf
#EndRegion IsAdmin

Func _IsAdministrator($sUser = @UserName, $sCompName = ".")
    Local $aCall = DllCall("netapi32.dll", "long", "NetUserGetInfo", "wstr", $sCompName, "wstr", $sUser, "dword", 1, "ptr*", 0)
    If @error Or $aCall[0] Then Return SetError(1, 0, False)
    Local $fPrivAdmin = DllStructGetData(DllStructCreate("ptr;ptr;dword;dword;ptr;ptr;dword;ptr", $aCall[4]), 4) = 2
    DllCall("netapi32.dll", "long", "NetApiBufferFree", "ptr", $aCall[4])
    Return $fPrivAdmin
EndFunc   ;==>_IsAdministrator
But i recently got a win_7 lapyop and installed the lateset autoit & Scite, and i now have the following problems:

When running scripts with the above code (and a admin account), the scripts elevates and then opening dlls fails, and reading INI files fails also.

When running scripts WITHOUT the above code (no admin account), then opening dlls works, and reading INI files works also.

is there anyway to read the user files once the process is elevated ?

i am trying to the app to run as admin if the user is admin, and run as user if not (which is working), but its painful that the files are unable to be read when running elevated ...

Link to comment
Share on other sites

If you have a problem reading ini-files or calling dll-files then post a reproducer (fully working example) that does just that. The only dll/ini stuff here is _IsAdministrator() which I doubt you have a problem with.

We can't help you if you give us nothing to work on, we are not mind-readers.

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