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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:56:06+00:00 2026-06-12T01:56:06+00:00

I have written a program on 1 PC, and tested out very carefully, everything

  • 0

I have written a program on 1 PC, and tested out very carefully, everything work fine.
But when I bring my .exe to another computer, it doesn’t
The problem I found is that it remembers the path of my first computer which is weird because I never hard-coded anything.

what this program does is firing a cmd that run java program using
Process.start();

this is the result:

javac: invalid flag: C:\Users\Lan
Usage: javac
use -help for a list of possible options

C:\Users\Lan Nguyen\Desktop\TestGrader\f1>

if you can see \TestGrader\f1; this is correct folder, it is where i want it to go. so the code works fine

but if you look at javac: invalid flag: C:\Users\Lan; this is the other computer where my code originally was made.

I do not know why this is the case, can someone help me fix it please.
Thank you.
btw, this has nothing to do with java, I just want to use c# to run a cmd that will later run java.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace Gui
{
    public partial class GradingProgram : Form
    {
        private String[] studentName;
        private int index = 0;
        String projectName, cmd, compileJava, runJava, path, unzip;

        public GradingProgram()
        {
            studentName = new String[50];
            InitializeComponent();
            cmd = "cmd";
            unzip = "/K rar x ";
            compileJava = "/K javac ";
            button3.Enabled = false;
            this.AutoSize = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderChooser = new FolderBrowserDialog();
            folderChooser.ShowDialog();
            path = folderChooser.SelectedPath;            
        }

        private void updateLabels()
        {
            textBox2.Clear();
            for (int i = 0; i < index; i++)
            {
                textBox2.AppendText(studentName[i]);
                textBox2.AppendText(Environment.NewLine);
            } 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            String currentDirectory;

            for (int i = 0; i < index; i++)
            {
                currentDirectory = @path + "\\" + studentName[i];
                Directory.SetCurrentDirectory(currentDirectory);
                foreach (String files in Directory.GetFiles(currentDirectory))
                {
                    if (Path.GetExtension(files) == ".java")
                    {
                        Process.Start(cmd, compileJava + files).WaitForExit();
                    }
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            projectName = textBox1.Text;
            runJava = "/K java " + projectName;
            String currentDirectory;
            for (int i = 0; i < index; i++)
            {
                currentDirectory = @path + "\\" + studentName[i];
                Directory.SetCurrentDirectory(currentDirectory);
                textBox3.ScrollBars = ScrollBars.Vertical;
                foreach (String files in Directory.GetFiles(currentDirectory))
                {
                    if (Path.GetExtension(files) == ".java")
                    textBox3.Text += File.ReadAllText(files);
                    textBox3.AppendText("------------------------------------------------------------");
                }
                Process.Start(cmd, runJava).WaitForExit();
                try
                {
                    textBox4.Text = File.ReadAllText(Directory.GetCurrentDirectory() + "\\" + "output.txt");
                }
                catch (Exception )
                {
                    textBox4.Text = "no output";
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Directory.SetCurrentDirectory(@path);
            foreach (String files in Directory.GetFiles(path))
            {
                if (Path.GetExtension(files) == ".rar")
                {
                    Process.Start(cmd, unzip + files).WaitForExit();
                }
            }

            foreach (String folder in Directory.GetDirectories(path))
            {
                studentName[index] = new DirectoryInfo(folder).Name;
                index++;
            }
            button4.Enabled = false;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            updateLabels();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (this.Text != "")
            {
                button3.Enabled = true;
            }
        }

    }
}
  • 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-12T01:56:07+00:00Added an answer on June 12, 2026 at 1:56 am

    Shouldn’t you be using something like this:

    runJava = String.Format(@"/K java ""{0}""", projectName);
    

    Because it seems that it fails with the space in your username.
    If you have accounts with the same name on both computers you also have two C:\Users\… directories.

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

Sidebar

Related Questions

I have written a small program just like hello the world , everything was
I've got a very simple program written in C#, but the loop never exits
I have written a program which will serialize and de-serialize, it does this fine
I have tested the encryption part of the program and it works just fine
I have written a program in clojure but some of the functions have no
I have written a Java program that should open another program (which is a
I have written a program for Bar code scanner application it works fine in
I have written php program and uploaded on server. I want run this program
I have written a program in VB6. When I compile it and send it
I have written a program that uses qhttp to get a webpage. This works

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.