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 8886495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:34:21+00:00 2026-06-14T21:34:21+00:00

I decided to use System.Diagnostics.Process to run a powershell script just because it seemed

  • 0

I decided to use System.Diagnostics.Process to run a powershell script just because it seemed simple,I didn’t care about the result output, and I wanted the user to be able to see what was running

Process process = new Process();

Process.StartInfo.FileName = "powershell.exe"
Process.StartInfo.Arguments = String.Format("-executionpolicy unrestricted -noexit \"{0}\" -XmlConfigFile {1}",scriptname, configFile);
process.Start();

When I run this the script sees no arguments. Due to the noexit I can test $args and $MyInvocation at the end. No arguments. If I run it in cmd.exe it works, If I leave off the {1} it complains about -XmlConfigFile missing an argument.

edit: turns out It was my fault I was running nested powershell sessions to deal with forcing powershell to use 4.0 and only passing along args which doesn’t include arguments in $psboundparameters.

  • 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-14T21:34:22+00:00Added an answer on June 14, 2026 at 9:34 pm

    Try this, as it works for me:

    Process.StartInfo.Arguments = String.Format("-executionpolicy unrestricted 
    -noexit -file \"{0}\" -XmlConfigFile {1}",scriptname, configFile);
    

    Though I dont know what -XmlConfigFile does. As it seems to be no valid argument:
    http://technet.microsoft.com/en-us/library/hh847736.aspx

    So you may remove it for a start.

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

Sidebar

Related Questions

I want to use some thing unique for a licensing system. i decided to
I've just started with C++ and I decided to use Visual C++. In the
I building a user system and decided to use the Gravatar (I know, I
Using C# 4.0, I've created a System.Diagnostics.Process that I expect to take a short
I'm making simple peer to peer game and I decided to use XML to
We have recently decided to use Maven as build system. I'm responsible to migrate
I was just writing a console utility and decided to use NDesk.Options for command-line
Decided to use Apache's Common Configuration package to parse an XML File. I decided
I recently decided to use Apache HTTPD (on CentOS - RPM version httpd-2.2.3-45.el5.centos) with
I've decided to use Entity Framework for O/R Mapping, and DataAnnotations for validation in

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.