Windows 10: How to run batch file with powershell Solved

  1.    03 Mar 2018 #1

    How to run batch file with powershell

    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... I figure 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) using power shell?

    Thank you

    edit.... 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.
      My ComputerSystem Spec

  2.    03 Mar 2018 #2

    Create a shortcut to your batch file (right-click drag+drop the file). Then edit the shortcut's Properties->Shortcut->Advanced.

    Click image for larger version. 

Name:	image.png 
Views:	21 
Size:	20.0 KB 
ID:	179347
      My ComputerSystem Spec

  3.    03 Mar 2018 #3

    Or you can auto elevate your .bat by sticking this at the start (copied from UUPtoISO)
    set "params=%*"
    cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
    Either way you'll get a UAC warning asking you to authorize running as Administrator. You can avoid this (see following tutorials...) if you want.

    If you are admin user: Create Elevated Shortcut without UAC prompt in Windows 10 Windows 10 Tutorials

    else (but a bit risky I think): Elevated Program Shortcut - Create for Standard User - Windows 7 Help Forums
      My ComputerSystem Spec

  4.    03 Mar 2018 #4

    thank you
      My ComputerSystem Spec


Related Threads
How can I add to this batch command to include the date: xcopy C:\all\* Z:\Allbak\* /E /Y /C I'd like the resulting file to be named "Z:\Allbak171129" (yr mo day). The plan is to set up a task schedule to run the batch file every week. I...
Startup batch file in General Support
When Windows 10 starts, a DOS window appears, runs: C:\Users\Brian\AppData\Local\854e8f7.bat , then disappears. The .bat file contains: start "plqcknRlU67iM4TfEXQq" "%LOCALAPPDATA%\b183312\88d4f24.21b2bbd3" There are two files in...
Need help with batch file in General Support
No serious Batch file or scripting experience, so bear with me. We use a site for our business that has to run on IE and has to have the cache cleared a certain way sometimes for it to function. We have to go IE options, uncheck delete history on...
Batch File Help in Software and Apps
I've never dabbled much in batch files, as I've usually been able to find pre-made ones to do what I wanted. We have an application that handles user data backups. It has three services, and at times, one or two of the three don't start...
Hi there forum, how do you change the Visual effects using a batch file or registry file. Thanks, Edward.
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 07:00.
Find Us