Post by IRBaboon » 02 Mar 2016, 05:32
Code: Select all
DllCall("shell32\ShellExecute", "uint", 0, "str", "RunAs", "str", "regsvr32", "str", Path, "str", A_WorkingDir, "int", 1) ;registers the dll with admin rights
hier wird das RunAs anscheinend nicht beachtet, die Fehlermeldung sagt das die Ressource nicht vorhanden ist. Wenn ich die Admin Abfrage separat einbaue, funktioniert es:
Code: Select all
#SingleInstance force
...
Loop
{
try
Id3Tag := ComObjCreate("ID3COM.ID3COMTag")
catch
{
if not A_IsAdmin
{
;das try/catch ist nötig um einen Benutzerabbruch mit einer ordentlichen Meldung abzufangen
try
Run *RunAs "%A_ScriptFullPath%"
catch {
MsgBox, 48, Error, The Program must be run as administrator on first run to register its ressources.
ExitApp
}
}
Path := "id3com.dll"
If !FileExist("id3com.dll")
{
MsgBox, 48, %Path% missing., Select location to %Path%
FileSelectFile,Path,3,id3com.dll,Please select id3com.dll,id3com.dll (id3com.dll)
}
If !Path
ExitApp
DllCall("shell32\ShellExecute", "uint", 0, "str", "RunAs", "str", "regsvr32", "str", Path, "str", A_ScriptDir, "int", 0) ;registers the dll with admin rights, last parameter nShowCmd=0 suppresses success message
If (A_LastError=1223) ; 1223 = Aborted by user
{
MsgBox, 48, Error, Could not register %Path%.
ExitApp
}
}
goto, Start
}
[code]DllCall("shell32\ShellExecute", "uint", 0, "str", "RunAs", "str", "regsvr32", "str", Path, "str", A_WorkingDir, "int", 1) ;registers the dll with admin rights[/code]
hier wird das RunAs anscheinend nicht beachtet, die Fehlermeldung sagt das die Ressource nicht vorhanden ist. Wenn ich die Admin Abfrage separat einbaue, funktioniert es:
[code]
#SingleInstance force
...
Loop
{
try
Id3Tag := ComObjCreate("ID3COM.ID3COMTag")
catch
{
if not A_IsAdmin
{
;das try/catch ist nötig um einen Benutzerabbruch mit einer ordentlichen Meldung abzufangen
try
Run *RunAs "%A_ScriptFullPath%"
catch {
MsgBox, 48, Error, The Program must be run as administrator on first run to register its ressources.
ExitApp
}
}
Path := "id3com.dll"
If !FileExist("id3com.dll")
{
MsgBox, 48, %Path% missing., Select location to %Path%
FileSelectFile,Path,3,id3com.dll,Please select id3com.dll,id3com.dll (id3com.dll)
}
If !Path
ExitApp
DllCall("shell32\ShellExecute", "uint", 0, "str", "RunAs", "str", "regsvr32", "str", Path, "str", A_ScriptDir, "int", 0) ;registers the dll with admin rights, last parameter nShowCmd=0 suppresses success message
If (A_LastError=1223) ; 1223 = Aborted by user
{
MsgBox, 48, Error, Could not register %Path%.
ExitApp
}
}
goto, Start
}[/code]