Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


How to run batch file, is power shell needed?

  • Please log in to reply
3 replies to this topic

#1 eeps24


  • Members
  • 8 posts
  • Local time:12:48 PM

Posted 03 March 2018 - 03:36 PM

I created a basic batch file that uses "net share" to share a local path. I saved the batch file. When I double click the file I get "access is denied"... note, I am logged on as a admin.

Anyways... if I right click the file and click "run as administrator" it runs fine. I want the ability to just double click it and execute.


I assume it has to be run using power shell. I do not know much about powershell. Can anyone tell me how I can run this batch file (by double clicking on the icon), do I need to run it with poweshell, if so, how?


Thank you


BC AdBot (Login to Remove)


#2 britechguy


    Been there, done that, got the T-shirt

  • Moderator
  • 9,867 posts
  • Gender:Male
  • Location:Staunton, VA
  • Local time:12:48 PM

Posted 03 March 2018 - 05:09 PM

What you need to understand is even if you are using an account with admin privilege (except, I believe, the hidden admin account itself) you do not have admin privilege unless you invoke it explicitly.


If you want to run a given .bat file with admin privileges the easiest thing to do is to create a shortcut to the actual .bat file (most often on the desktop, but it could be anywhere) then opening the shortcut properties, activating the Advanced button, and checking the checkbox for "Run as administrator."   I use this technique for several scripts that need to reset the system date temporarily, which you cannot do except if running as admin in a batch file, and then change it back.  The "Run as administrator" advanced property is only present, to my knowledge on shortcuts, not native .exe files, .bat files, or .ps1 [PowerShell script] files.

Brian  AKA  Bri the Tech Guy (website in my user profile) - Windows 10 Home, 64-Bit, Version 1809, Build 17763 

Travel is fatal to prejudice, bigotry, and narrow-mindedness, and many of our people need it sorely on these accounts.  Broad, wholesome, charitable views of men and things cannot be acquired by vegetating in one little corner of the earth all one's lifetime.

       ~ Mark Twain






#3 eeps24

  • Topic Starter

  • Members
  • 8 posts
  • Local time:12:48 PM

Posted 03 March 2018 - 09:46 PM

thank you.


not sure how to mark this thread as solved.

Edited by eeps24, 03 March 2018 - 09:47 PM.

#4 RolandJS


  • Members
  • 4,552 posts
  • Gender:Male
  • Location:Austin TX metro area
  • Local time:11:48 AM

Posted 03 March 2018 - 10:33 PM

Threads are never closed; they remain open for reading by others and the occasional comments.   :)

"Take care of thy backups and thy restores shall take care of thee."  -- Ben Franklin revisited.


Backup, backup, backup! -- Lady Fitzgerald (w7forums)

Clone or Image often! Backup... -- RockE (WSL)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users