mIRC Home    About    Download    Register    News    Help

Print Thread
#260010 18/02/17 01:06 PM
Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
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.

klez #260015 19/02/17 04:09 AM
Joined: Aug 2016
Posts: 36
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.

Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Thank you very much.. works! smile

Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
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?

klez #260027 20/02/17 04:14 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #260044 22/02/17 02:06 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
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!

Link Copied to Clipboard