source:
Code: Select all
"ToggleRunAsAdmin : adminrun"
/* RunAsAdmin toggle//SammaySarkar//Jun-16-2014 11:07:18 PM
toggles the Run as Admin compatibility option for all exe files in selection. */
$sel = get("SelectedItemsPathNames", '|'); $a = "HKCU"; $b = '';
//$b = (%osbitness% == 64)?' /reg:64':'';
//apply for all users: Run XY as admin, set $a = "HKLM" and if 64bit OS, uncomment the cmd above
foreach ($itm, $sel, '|'){
if ( (exists("$itm") == 1) && (getpathcomponent($itm, ext) == "exe") ){//step;
//obtain current compatibility value
$currReg = replace(gettoken(runret("%COMSPEC% /c reg.exe query ""$a\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""$itm""$b"),-1," "),<crlf>);
//toggle
if (strpos($currReg, "RUNASADMIN") != -1){
//if set, negate RUNASADMIN from data
$value = replace($currReg, "RUNASADMIN", "");
if (replace($value, " ") == ""){
//if negating turns out to empty the data, delete the value and continue to next $itm
run "reg.exe delete ""$a\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""$itm"" /f$b",, 2, 0;
continue;
}
}
else {
//else add RUNASADMIN
$value = $currReg." RUNASADMIN";
}
run "reg.exe add ""$a\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"" /v ""$itm"" /d ""$value"" /f$b",, 2, 0;
}
}
status "Done. Check each file's Properties->Compatibility.";
Obligatory Note: by design it alters the registry (although toggling back will undo the alteration)
XYplorer Beta Club