home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 42,102 of 42,547   
   JJ to All   
   Re: I need to check if I am running as A   
   12 Nov 22 19:05:17   
   
   From: jj4public@outlook.com   
      
   On Fri, 11 Nov 2022 23:27:32 -0800, T wrote:   
   > On 11/11/22 23:23, T wrote:   
   >>   
   >> Windows 11 pro 22H2   
   >>   
   >> C:\NtUtil>type Windows.RaidCheck.pl6.bat   
   >> @echo off   
   >> fsutil /? > nul   
   >> echo %ERRORLEVEL%   
   >>   
   >> As an administrator:   
   >> C:\NtUtil>Windows.RaidCheck.pl6.bat   
   >> 1   
   >>   
   >> This is because   
   >>     fsutil /?   
   >>     /? is an invalid parameter.   
   >>   
   >> RATS !!!   
   >>   
   >   
   > Hi JJ,   
   >   
   > You put me on the right path though   
   >   
   > As a user:   
   >   
   > net sessions & echo %ERRORLEVEL%   
   > System error 5 has occurred.   
   >   
   > Access is denied.   
   >   
   > 2   
   >   
   > As an Administrator:   
   >   
   > net sessions & echo %ERRORLEVEL%   
   > There are no entries in the list.   
   >   
   > 0   
   >   
   > Thank you!   
      
   Whoops. With fsutil, the /? shouldn't be specified. i.e. just `fsutil`   
   without any command line argument.   
      
   Another alternative which is longer to type but not without advantages, is   
   to simply check the content of the `systemprofile` folder. e.g.   
      
   @echo off   
   if exist %systemroot%\system32\config\systemprofile\* (   
     echo elevated   
   ) else (   
     echo not elevated   
   )   
      
   Or try going into that folder...   
      
   @echo off   
   2>nul pushd %systemroot%\system32\config\systemprofile   
   if errorlevel 1 (   
     echo not elevated   
   ) else (   
     popd   
     echo elevated   
   )   
      
   The advantages of checking that folder is because it's faster than executing   
   a tool. And a tool may be blocked by group policy, or be excluded by   
   debloater software from the OS installer to create a minimal OS installation   
   which is intended to only do specific thing.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca