Batchography: How to check if your Batch file script is running as an Administrator

In chapter 4 of the Batchography book, I illustrate 3 methods that you can use to check if your Batch file script is running as an Administrator.

In this blog post, I will share with you the method entitled “Using known commands that fail to run without elevated privileges” from the book.

The idea behind this method is to run commands that are known to fail and return a non-zero error code if they are not executed with administrative privilege.

The Batch script would then check the return code and act accordingly:

@echo off


:: 
:: The Batchography book by Elias Bachaalany
::


net session >nul 2>&1

if %errorlevel% neq 0 (
  echo Requires administrative privilege.
  goto :eof
)

echo Script starts here...

flower separator
batchography-good-resDo you want to master Batch Files programming?

Look no further, the Batchography is the right book for you.

Available in print or e-book editions from Amazon.com!

 

flower separatorYou might also like:

Technical cheat sheets

This article is compilation of the various blog posts that contain a set of steps, table of hotkeys and shortcuts and/or other quick information for reference purposes.
cheat sheet
The list below will be updated when new relevant articles are posted in this blog:

Stay tuned!

flower separatorYou might also like:

Seven Golden Keys for Good Health – an advice from Dr. Shinya

fruit-basketI ran into the following article when researching the topic of Kangen Water.

The contents of this blog post has been compiled from excerpts from the “The Enzyme Factor Paperback – April 1, 2010 by Hiromi Shinya MD” book.

I find this article very useful, therefore I am sharing with you slightly modified version of it. It will contain 7 important diet and mental attitude tips to inspire you to have good health and longer life.

Make sure you check the other recommended articles.

flower separator

1. GOOD DIET

You should be consuming 85-90% plant based foods and 10-15% animal based food and proteins.

Plant-based foods

Eat a 85-90% plant-based foods:

  • Eat 50% whole grains, brown rice, whole wheat pasta, barley, cereals, whole grain bread & beans including soybeans, kidney beans, garbanzo beans, lentils, pinto beans, pigeon peas, black, white & pink beans.
  • Eat 30% green and yellow vegetables and root vegetables, including potatoes, carrots, yams and beets and sea vegetables.
  • With the remaining 5-10%, eat fruits, seeds & nuts.

Continue reading “Seven Golden Keys for Good Health – an advice from Dr. Shinya”