Hi!
Can I detect if the user has started the compiled .exe as "Run as Administrator"?
If The user does this then some things are different and I must fix that. Like Mapped drive letters and certificates.
Thanks!
Detect if run as Administrator?
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
Re: Detect if run as Administrator?
Test for something the admin has that the user does not. A file or a drive might work.
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
Re: Detect if run as Administrator?
Thanks.
I was thinking that You could read the RP_ADMIN variable or something like that for that info.
This appears to work
I was thinking that You could read the RP_ADMIN variable or something like that for that info.
This appears to work
Code: Select all
Let>WLN_NOCRLF=1
WriteLn>c:\windows\system32\drivers\etc\hosts,x,
If>x=0
MessageModal>Administrator
else
MessageModal>User
endif
Re: Detect if run as Administrator?
Alternative Version:
Code: Select all
Let>nWLNRes=
WriteLn>C:\text.txt,nWLNRes,
IFNOT>nWLNRes=0
MessageModal>!!!Please Run as Admin!!!
Exit
ENDIF
Re: Detect if run as Administrator?
Good one!
I would add an Else to delete the test.txt file
I would add an Else to delete the test.txt file
Code: Select all
Let>nWLNRes=
WriteLn>C:\text.txt,nWLNRes,
IFNOT>nWLNRes=0
MessageModal>!!!Please Run as Admin!!!
Else
MDL>Yippie !!!
DeleteFile>C:\text.txt
ENDIF
Exit>