mIRC Home    About    Download    Register    News    Help

Print Thread
#260009 18/02/17 12:48 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 $isadmin? I don't know so well $com objects and if somebody is glad to help me, i'll be very thankful.

The idea is simple: i need to know if mirc.exe is running as administrator or not! Please don't confuse with the item if a windows account is an administrator or standard account. I need to know if mirc.exe when opens is running as administrator (right-click mirc.exe -> run as administrator or is set in Proprieties\Compatibility -> Run as administrator) or not. $isadmin must return $true or $false.

Thank you and hope for your help.

P.S. Someone provide me an example, but it not works:

Code:
; $isadmin
; Returns $true or null

alias isadmin {
  if (!$isid) return
  set -l %a isadmin_ $+ $ticks $+ $rand(1111,9999))
  if ($com(locator_ $+ %a)) .comclose locator_ $+ %a
  .comopen locator_ $+ %a WbemScripting.SWbemLocator
  if ($comerr) return
  if ($com(services_ $+ %a)) .comclose services_ $+ %a
  if (!$com(locator_ $+ %a,ConnectServer,3,dispatch* services_ $+ %a)) || ($comerr) return
  .comclose locator_ $+ %a
  if ($com(os_ $+ %a)) .comclose os_ $+ services_ $+ %a
  if (!$com(services_ $+ %a,ExecQuery,3,bstr,Select * from Win32_OperatingSystem,dispatch* os_ $+ %a)) || ($comerr) return
  .comclose services_ $+ %a
  if ($com(os_ $+ %a,Count,3)) && ($comval(os_ $+ %a,1,SystemDirectory)) set -l %sysdir $v1 $+ \
  else return
  .comclose os_ $+ %a
  .fopen -o %a $qt(%sysdir $+ %a $+ .tmp)
  .fwrite %a $!true
  .fclose %a
  set -l %read $read(%sysdir $+ %a $+ .tmp)
  .remove $qt(%sysdir $+ %a $+ .tmp)
  return %read
}

Last edited by klez; 18/02/17 12:56 PM.
Joined: Aug 2016
Posts: 57
R
Babel fish
Offline
Babel fish
R
Joined: Aug 2016
Posts: 57
Test this code here.
Code:
alias isadmin {
  if (!$isid) return
  set -l %elevated $false
  set -l %a $ticks $+ $rand(1111,9999)
  if ($com(shell $+ %a)) .comclose shell $+ %a
  .comopen shell $+ %a WScript.Shell
  if ($comerr) goto end
  if (!$com(shell $+ %a,Run,1,bstr,cmd.exe /c whoami /groups > %a $+ .tmp,int,0,bool,true)) goto end
  if ($read(%a $+ .tmp,w,*S-1-16-12288*)) %elevated = $true
  :end
  if ($com(shell $+ %a)) .comclose shell $+ %a
  if ($isfile(%a $+ .tmp)) .remove %a $+ .tmp
  return %elevated
}


rockcavera
#Scripts @ irc.VirtuaLife.com.br
Joined: Sep 2015
Posts: 101
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 101
Thank you very much, but appears UAC due to cmd.exe init smile

If you can help me with UAC from the next post from this section, i'll be very happy and thankful..

P.S. I think to remain on the idea to use /fwrite and $read on the path where can write with admin rights only (usually C:\ or C:\Windows etc.), to know if mirc.exe is running as administrator or not.


I also agree with the fact to close this thread and thank you very much for your help and attention.

Last edited by klez; 18/02/17 08:44 PM.

Link Copied to Clipboard