Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:50:05+00:00 2026-06-11T22:50:05+00:00

I am setting execution policy rights to PowerShell through a batch file to allow

  • 0

I am setting execution policy rights to PowerShell through a batch file to allow running of PowerShell scripts.

Windows PowerShell has execution policy as Restricted by default. Yes we can start PowerShell with elevated (admin) rights and set policy as Unrestricted manually.

Now the question is if we can set it manually then is it makes sense to set it via batch file?

When you need to run your script file on multiple machines (say for testing purpose) it could be a hassle setting policy rights to each machine manually. Although it is not much of a work for a person but this could be an overhead when you ask users to do this setting for themselves. Some users prefer to do as least as possible to make things work.

So the idea is user just need to execute the batch file with admin
rights which will set the policy rights automatically. The path to
execute the script should not be a problem because both the batch file
and PowerShell script would be in same folder (recommended).

This is what i have tried so far in my batch (.bat) file.

powershell.exe -Set ExecutionPolicy Unrestricted -FILE file.ps1 "args[0]" "args[1]"....

Where file.ps1 is the name of PowerShell script and args[0], args[1],…. are the optional arguments passed to the script.

The only thing which is not working here is the execution policy. It could be some syntax issue also. Please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:50:06+00:00Added an answer on June 11, 2026 at 10:50 pm

    This is the solution which worked for me.

    @powershell -ExecutionPolicy Unrestricted -FILE file.ps1 "args[0]" "args[1]" "args[2]"
    

    Eventually, the problem was with the syntax as you can notice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Depending on the method I used to get the execution policy setting for PowerShell,
Setting up new git installations. On one Windows laptop, I'm running (under cygwin): git
MacGDBp has a setting called Break on first line of execution, which I turned
I have a following batch file echo Setting visual studio 2010 environment variables set
Setting default values for System Configuration fields is well understood (via Chapagain and blog
When Python is first installed, the default setting executes users' code input line-by-line. But
I'm attempting to execute an uninstaller (written in AppleScript) through AuthorizationExecuteWithPrivileges. I'm setting up
I need to delay the execution of the 2nd function crumble() after stackUp() has
I would like to run dozens of long-running PHP scripts simultaneously, using XAMPP. Each
I'm building some servers and need to run some powershell scripts on them. However,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.