YTSJim Posted July 18, 2011 Share Posted July 18, 2011 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 ;==>_IsAdministratorBut 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 More sharing options...
YTSJim Posted July 18, 2011 Author Share Posted July 18, 2011 Im sure the above has been asked previously in this forum, but hours of searching have not lead me to the correct answer ... TIA for any responses Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 18, 2011 Share Posted July 18, 2011 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. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
trancexx Posted July 18, 2011 Share Posted July 18, 2011 Yea, we are the Borg. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 18, 2011 Share Posted July 18, 2011 Lower your shields and surrender your ships. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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