Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com

Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
I wanted to call from batch file powershell script that required administrative privileges.
I needed to check, if it was started as Administrator and also set current directory where the batch is located.
Thanks to couple of stackoverflow questions I've got this batch

@echo off
goto check_Permissions
:process
powershell &:: TODO the script to call
@pause
goto end
:check_Permissions
    net session >nul 2>&1
    if %errorLevel% == 0 (
        @rem echo Success: Administrative permissions confirmed.
          goto process
    ) else (
        echo Administrative permissions required.
    )
    pause >nul
:end
Posted on Wednesday, January 27, 2016 9:04 PM Batch files/PowerShell | Back to top


Comments on this post: Batch file that required administrative privileges.

# re: Batch file that required administrative privileges.
Requesting Gravatar...
how do u post a blog? i tried posting blog on this site but it never show up on homepage. not even most recent.
Left by jc on Jan 27, 2016 11:55 PM

# re: Batch file that required administrative privileges.
Requesting Gravatar...
@jc. You should login as admin, create a new post and at the bottom ensure in Advanced Options ticked Published, Show on my blog, Show on GWB. What is your blog name?
Left by Michael Freidgeim on Jan 28, 2016 10:17 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net