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.

Photo

How to run batch file, is power shell needed?


  • Please log in to reply
3 replies to this topic

#1 eeps24

eeps24

  • Members
  • 8 posts
  • OFFLINE
  •  
  • Local time:02:49 AM

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

britechguy

    Been there, done that, got the T-shirt


  • Moderator
  • 8,981 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Staunton, VA
  • Local time:03:49 AM

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 1803, Build 17134 

     . . . the presumption of innocence, while essential in the legal realm, does not mean the elimination of common sense outside it.  The willing suspension of disbelief has its limits, or should.

    ~ Ruth Marcus,  November 10, 2017, in Washington Post article, Bannon is right: It’s no coincidence The Post broke the Moore story


 

 

 

              

 


#3 eeps24

eeps24
  • Topic Starter

  • Members
  • 8 posts
  • OFFLINE
  •  
  • Local time:02:49 AM

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

RolandJS

  • Members
  • 4,533 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Austin TX metro area
  • Local time:02:49 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.

http://collegecafe.fr.yuku.com/forums/45/Computer-Technologies/

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