mIRC Home    About    Download    Register    News    Help

Print Thread
Need $uac script. #260010 18/02/17 01:06 PM
Joined: Sep 2015
Posts: 88
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 88
Hi!

Can somebody help me with creating $uac? I don't know so well $com objects and if somebody is glad to help me, i'll be very thankful.

Using $uac identifier, I want to know before running an app/file will popup UAC confirmation (system dialog) or not.
For example:

Code:
//echo -a $uac(C:\mIRC\mIRC.exe)


will return $true if the UAC confirmation appears when i execute /run C:\mIRC\mIRC.exe or returns $false if the UAC confirmation don't appears.

Thank you and hope for your help.

Re: Need $uac script. [Re: klez] #260015 19/02/17 04:09 AM
Joined: Aug 2016
Posts: 36
ruprecht Offline
Ameglian cow
Offline
Ameglian cow
Joined: Aug 2016
Posts: 36
This script may help. You can check if the UAC is enabled, and what level the prompt is set at.

Code:
alias uac {
  var %v = HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\
  var %v = %v $+ $gettok(EnableLUA ConsentPromptBehaviorAdmin ConsentPromptBehaviorUser,$1,32)
  if ($com(uac)) .comclose uac
  .comopen uac WScript.Shell
  noop $com(uac,RegRead,3,bstr,%v)
  return $com(uac).result
}


$uac(1) will return 0 if UAC is disabled, 1 if enabled
$uac(2) will return a level from 0 to 3 for an admin account
$uac(3) will return a level from 0 to 3 for a normal user account

Note that UAC can be enabled with the prompt set to 0 for an admin account which will not pop up the dialog. It's up to you to work out how to use this info.

Re: Need $uac script. [Re: ruprecht] #260016 19/02/17 07:18 AM
Joined: Sep 2015
Posts: 88
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 88
Thank you very much.. works! smile

Re: Need $uac script. [Re: ruprecht] #260017 19/02/17 07:30 AM
Joined: Sep 2015
Posts: 88
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 88
But please, if you can provide me a script how to write in regedit thruugh $com objects, i mean i want to change ConsentPromptBehaviorAdmin for example.. how to do it?

Re: Need $uac script. [Re: klez] #260027 20/02/17 04:14 PM
Joined: Jul 2006
Posts: 3,622
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,622
Code:
alias regwrite {
  .comopen rr WScript.Shell
  if ($prop == key) var %ok $com(rr,RegWrite,3,bstr,$1,int,,bstr,REG_SZ)
  else var %ok $com(rr,RegWrite,1,bstr,$1,bstr,$2,bstr,$iif(!$prop || $prop == string,REG_SZ,REG_DWORD))
  .comclose rr
  return %ok
}

To add a key: $regwrite(<path>).key
<path> must end with a backslash otherwise you're setting a keyvalue

To add a key+value to a key:

add an int: $regwrite(<path>,<number>).int
add a string: $regwrite(<path>,<string>)
This time <path> must not end with a backslash

Example:
//echo -a $regwrite(HKCU\Software\mIRC\test\).key
//echo -a $regwrite(HKCU\Software\mIRC\test\test,5).int
//echo -a $regwrite(HKCU\Software\mIRC\test\test1,test)

https://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.84).aspx

Last edited by Wims; 20/02/17 04:14 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Need $uac script. [Re: Wims] #260044 22/02/17 02:06 PM
Joined: Feb 2003
Posts: 2,681
Raccoon Online
Hoopy frood
Online
Hoopy frood
Joined: Feb 2003
Posts: 2,681
IsAdmin { var %file = $regsubex($envvar(SystemDrive),/\\?$/,\) $+ admintest $+ $ticks $+ $r(1,999999999999) | .fopen -no admintest $qt(%file) | .fclose admintest | var %rslt = $exists(%file) | if (%rslt) .remove $qt(%file) | if (!$isid) echo -a * IsAdmin: %rslt | return %rslt } ; by Raccoon 2017
Code:
IsAdmin {
  var %file = $regsubex($envvar(SystemDrive),/\\?$/,\) $+ admintest $+ $ticks $+ $r(1,999999999999)
  .fopen -no admintest $qt(%file)
  .fclose admintest
  var %rslt = $exists(%file)
  if (%rslt) .remove $qt(%file)
  if (!$isid) echo -a * IsAdmin: %rslt
  return %rslt
} ; by Raccoon 2017


Well. At least I won lunch.
Good philosophy, see good in bad, I like!