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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:38:08+00:00 2026-05-11T14:38:08+00:00

Looks like it’s not. If I convert the file name to its short value,

  • 0

Looks like it’s not.

If I convert the file name to its short value, then Process.Start() works.

Process runScripts = new Process(); runScripts.StartInfo.FileName = @'C:\long file path\run.cmd'; runScripts.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; runScripts.StartInfo.UseShellExecute = true; runScripts.StartInfo.RedirectStandardOutput = false; runScripts.Start(); 

The above code fails. But…

Process runScripts = new Process(); runScripts.StartInfo.FileName = @'C:\short\file\path\run.cmd'; runScripts.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; runScripts.StartInfo.UseShellExecute = true; runScripts.StartInfo.RedirectStandardOutput = false; runScripts.Start(); 

succeeds.

I managed to get around this by converting the long path name to a short path name. But I am a bit surprised to find this. Any reasons or background info on this?

Thanks.

Update 1
Microsoft .NET Framework Version 2.0.50727

  • 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. 2026-05-11T14:38:09+00:00Added an answer on May 11, 2026 at 2:38 pm

    To reproduce your problem, I used the following program:

    // file test.cs using System; using System.ComponentModel; using System.Diagnostics;  public class Test {     public static int Main()     {         string error;         try {             ProcessStartInfo i = new ProcessStartInfo();             i.FileName = @'C:\long file path\run.cmd';             i.WindowStyle = ProcessWindowStyle.Hidden;             i.UseShellExecute = true;             i.RedirectStandardOutput = false;             using (Process p = Process.Start(i)) {                 error = 'No process object was returned from Process.Start';                 if (p != null) {                     p.WaitForExit();                     if (p.ExitCode == 0) {                         Console.ForegroundColor = ConsoleColor.Green;                         Console.WriteLine('OK');                         Console.ResetColor();                         return 0;                     }                     error = 'Process exit code was ' + p.ExitCode;                 }             }         }         catch (Win32Exception ex) {             error = '(Win32Exception) ' + ex.Message;         }         Console.ForegroundColor = ConsoleColor.Red;         Console.WriteLine('Whooops: ' + error);         Console.ResetColor();         return 1;     } } 

    The code starts a new process (as per your code sample) and reports the different ways in which it may fail to execute. You can compile the program from command line:

    c:\windows\Microsoft.NET\Framework\v2.0.50727\csc test.cs 

    (assuming test.cs is in the current directory; it will create test.exe in the same directory as test.cs)

    As expected, when ‘C:\long file path\run.cmd’ does not exist, the program fails with:

    Whooops: (Win32Exception) The system cannot find the file specified 

    Now let’s create a directory ‘C:\long file path’ and put a very simple run.cmd in there:

    rem file run.cmd echo I ran at %Time% > '%~dp0\run.out.txt' 

    However, at this point I was unable to reproduce your failure. Once the above run.cmd is in place, test.exe runs successfully (i.e. run.cmd is executed correctly – you can verify this by looking for a newly created file ‘C:\long file path\run.out.txt’.

    I ran test.exe on Vista x64 (my main dev machine), Windows XP SP3 x86 (virtual machine), Windows Server 2008 x64 (virtual machine) and it works everywhere.

    Could you try running the above code in your environment and report back whether it is failing for you? This way we will at least establish the same testing context (same .NET program will be trying to run the same batch file in the same location for you as it does for me).

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

Sidebar

Related Questions

Looks like its related to NSURLConnection, but not sure how I can diagnose? Exception
Looks like XSD.exe is not delivered as a part of Visual Studio 2010. what
Looks like IDEA is not supporting the extssh protocol for connecting to CVS by
Looks like my shared hosting plan does not cover running a Jabber server. Does
Looks like set does not work in velocity when written as below : #set
Looks like libxslt does not support XSLT 2.0, and xsl:result-document . Is there a
Looks like EF Reference.Load() is not working without MARS? Is that right?
Looks like the following Ellipse in ControlTemplate does not get the BorderThickness, but why?
Looks like _compile_select is deprecated and get_compiled_select is not added to 2.1.0. Are there
Looks like I didn't set up my actor correctly, but not sure how else

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.