Code: Select all
; ===============================================================================================================================
; Title .........: NoUAC
; AHK Version ...: 1.1.25.01 x64 Unicode
; Win Version ...: Windows 10 Professional x64 / 1607 Build 14393.693
; Description ...: erstellt eine Verknüpfung auf dem Desktop ohne lästige Abfrage der Benutzerkontensteuerung beim Ausführen
; Version .......: v1.11
; Modified ......: 2017-03-15 10:16
; Author(s) .....: moefr01
; GUI Change ....: best-code-in-use
; ===============================================================================================================================
#NoTrayIcon
#SingleInstance force ; wichtig, damit die alte Instanz ohne Nachfrage beendet wird
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
Gui, Add, Text, x10 y10 w320 h40 vText, NoUAC - Erstellen Sie im Handumdrehen eine Verknüpfung zu Anwendungen ohne lästige Abfrage der Benutzerkontensteuerung beim Ausführen.
Gui, Add, Text, x10 y65, Im Akkubetrieb (für Windows Notebooks oder Tablets):
Gui, Add, Radio, x10 y85 vRadio0 gRadio Checked, aktiviert
Gui, Add, Radio, x68 y85 vRadio1 gRadio, deaktiviert
Gui, Add, Text, x100 y116 vText0, Aufgabenordner:
Gui, Add, Edit, x190 y112 w150 h20 vEingOrdner
Gui, Add, Text, x10 y144 vText1, Aufgabenname:
Gui, Add, Edit, x90 y140 w250 h20 vEingTaskname
Gui, Add, Text, x10 y172 vText2, Anwendung:
Gui, Add, Edit, x90 y168 w220 h20 vEingProgrammpfad
Gui, Add, GroupBox, x10 y200 w330 h160 vGroup1 BackgroundTrans,
Gui, Add, Picture, x20 y220 w48 h48 vIcon,
Gui, Add, Text, x20 y270 w310 h80 vAusgabe,
Gui, Add, Button, x310 y167 h22 w30 vfsButton gfsButton, ...
Gui, Add, Button, x200 y368 w140 vErstellenButton gErstellenButton, Verknüpfung erstellen...
Gui, Show, w350 h200, NoUAC
batterystop:="false"
Return
Radio:
GuiControlGet, aktiv, , Radio0
If (aktiv)
batterystop:="false"
Else
batterystop:="true"
Return
; Dateiauswahldialog starten
fsButton:
FileSelectFile, programmpfad, 1, , Bitte ausführbare Datei auswählen:, Ausführbare Datei (*.exe)
GuiControl, , EingProgrammpfad, %programmpfad%
GuiControl, , Icon, %programmpfad%
GuiControlGet, taskname, , EingTaskname
GuiControlGet, ordnername, , EingOrdner
taskname0 = %taskname%
taskname = "%ordnername%\%taskname%"
GuiControlGet, programmpfad, , EingProgrammpfad
programmpfad0 = %programmpfad%
programmpfad = "%programmpfad%"
; Formatierungen
Ausgabetext = Verknüpfung:`n%A_Desktop%\%taskname0%`n`nPfad:`n%Windir%\System32\schtasks.exe /RUN /TN %taskname%
GuiControl, , Ausgabe, %Ausgabetext%
Gui, Show, w350 h400, NoUAC
Return
ErstellenButton:
If (taskname0 = "") or (programmpfad0 = "") {
MsgBox, , ACHTUNG!, Es wurden keine Eingaben gemacht oder eine Verknüpfung bereits erstellt.
Return
}
; erstellt Verknüpfung auf dem Desktop: minimiert, erstes Icon von exe, mit Tasknamen
FileCreateShortcut, "%Windir%\System32\schtasks.exe", %A_Desktop%\%taskname0%.lnk, , /RUN /TN %taskname%, ...erstellt am %A_DD%.%A_MM%.%A_YYYY%, %programmpfad0%, , , 7
; erstellt Aufgabe in der Aufgabenplanung
Run, %Windir%\system32\schtasks.exe /create /sc beimstart /tn %taskname% /tr %programmpfad% /rl höchste, , hide
Sleep, 500
userid:=A_ComputerName "\" A_UserName
FileDelete, %taskname0%.xml
FileAppend,
(
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<URI>\fmwSystemImager</URI>
</RegistrationInfo>
<Principals>
<Principal id="Author">
<UserId>%userid%</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>%batterystop%</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>%batterystop%</StopIfGoingOnBatteries>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%programmpfad%</Command>
</Exec>
</Actions>
</Task>
), %taskname0%.xml
RunWait, %Windir%\system32\schtasks.exe /create /xml %taskname0%.xml /tn %taskname% /f, , hide
MsgBox, 0x40, , Die %taskname0%-Verknüpfung zu %programmpfad% wurde erfolgreich auf dem Desktop angelegt.
GuiControl, , EingOrdner
GuiControl, , EingTaskname
GuiControl, , EingProgrammpfad
FileDelete, %taskname0%.xml
taskname0 =
programmpfad0 =
Return
GuiClose:
ExitApp