I tried to translate it into AHK. This is the first example. I haven't tested it. Please use it very carefully. You have to know what you are doing. E.g. you have to create the extra admin accounts, and other stuff, see blog.
Do you think there are any security concerns using this AHK code instead of the original scripts?
Edit:
060126: fixed some typos. Still not tested.
/* A remake of MachMichAdmin v.2 (c) 2005 c't und Johannes Endres <[email protected]> which is an improved script by Aaron Margosis http://blogs.msdn.com/aaron_margosis/archive/2005/03/11/394244.aspx */ StringRight, Lng, A_Language, 2 If Lng = 07 ; = german { _Admin_ = Verwalter _Group_ = Administratoren withGroupRights = mit %_Group_%-Rechten starts = startet } Else ; = other languages { _Admin_ = Caretaker _Group_ = Administrators withGroupRights = with %_Group_%-rights starts = starts } _Default_Prog_ = %comspec% /T:4F /k Title *** %USERNAME% %withGroupRights% *** CommandLinePara = Loop, %0% CommandLinePara = %CommandLinePara% %A_Index% If CommandLinePara is space _Program_to_Run_ = %_Default_Prog_% Else { _Program_to_Run_ = %TEMP%\%A_ScriptName%_temp.cmd IfExist, %_Program_to_Run_% { FileDelete, %_Program_to_Run_% If ErrorLevel { If Lng = 07 ; = german MsgBox, 4112, Fehler, Konnte die temporäre Datei "%_Program_to_Run_%" nicht löschen. Else MsgBox, 4112, Error, Couldn't remove the temporary file "%_Program_to_Run_%". ExitApp } } FileAppend, ( title %USERDOMAIN%\%USERNAME% %withGroupRights% %starts% %A_ScriptName% color 4f start "%_Group_%-Shell" %CommandLinePara% ), %_Program_to_Run_% _Program_to_Run_ = %comspec% /c %TEMP%\%A_ScriptName%_temp.cmd } If A_IsAdmin GoSub, already_admin if A_OSVersion not in WIN_2003,WIN_XP,WIN_2000 GoSub, usage If 1 in /?,-?,/h,-h,-help,--help GoSub, usage If 1 = _Second_Run_ GoSub, SecondRun StoreCurrentWorkDir = %A_WorkingDir% SetWorkingDir, %A_ScriptDir% If Lng = 07 InputBox, AdminPassword, %_Admin_% Passwort, Bitte das Passwort für %_Admin_% eingeben, HIDE Else InputBox, AdminPassword, %_Admin_% Password, Please input password for %_Admin_%, HIDE RunAs, %_Admin_%, %AdminPassword%, %COMPUTERNAME% If A_IsCompiled Run, %A_ScriptName% _Second_Run_ %USERNAME% %USERDOMAIN% "%_Program_to_Run_%" Else Run, autohotkey.exe %A_ScriptName% _Second_Run_ %USERNAME% %USERDOMAIN% "%_Program_to_Run_%" RunAs SetWorkingDir, %StoreCurrentWorkDir% ExitApp Return secondrun: ;the script has now admin rights _User_Name_ = %2% _User_Domain_ = %3% _Program_to_Run_ = %4% If Lng = 07 InputBox, UserPassword, %_User_Name_% Passwort, Bitte das Passwort für %_User_Name_% eingeben, HIDE Else InputBox, UserPassword, %_User_Name_% Password, Please input password for %_User_Name_%, HIDE Run, %systemroot%\system32\net.exe localgroup %_Group_% "%_User_Domain_%\%_User_Name_%" /ADD RunAs, %_User_Name_%, %UserPassword%, %_User_Domain_% Run, %_Program_to_Run_% RunAs Run, %systemroot%\system32\net.exe localgroup %_Group_% "%_User_Domain_%\%_User_Name_%" /DELETE ExitApp Return already_admin: If Lng = 07 MsgBox, 4160, Sie sind Admin, Sie sind bereits Mitglied der Gruppe %_Group_%.`nDaher wird das Programm nun direkt gestartet. Else MsgBox, 4160, You are admin, You are already a member of the %_Group_% group.`nHence, the program will be execuated directly. Run, %_Program_to_Run_% ExitApp Return usage: If Lng = 07 MsgBox, 64, Benutzung von %A_ScriptName%, (LTrim Führt ein Programm unter dem aktuellen Benutzeraccount jedoch mit Administrator-Rechten aus. Dieses Skript funktioniert nur unter Windows 2000, XP und Server 2003. %A_ScriptName% [Programm [Optionen]] Programm - Das Programm, das mit Administrator-Rechten laufen soll. Wenn dieserParameter fehlt, startet %_Default_Prog_% ) Else MsgBox, 64, Usage of %A_ScriptName%, (LTrim Executes a program with the current user account but with administrator rights. This Script is working only under Windows 2000, XP and Server 2003. %A_ScriptName% [Program [Options]] Program - The program, which will be executed with administrator-rights. If this program is left blank, this will be executed: %_Default_Prog_% ) ExitApp Return