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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:45:53+00:00 2026-06-04T23:45:53+00:00

Here be my stupid ? of the day. The following code will not run

  • 0

Here be my stupid ? of the day. The following code will not run in order, (as in top to bottom), it starts top skips to bottom then runs middle. IT will on the other hand run top down if i put a Console.WriteLine(); and Console.ReadKey(true); in the middle but i would like it to run straight through without interruption. I hope this makes since. I’m not sure if this has anything to do with it, but I’m trying to use a shell program (adb.exe) with this and not sure if that is throwing things off or not. thank you for any help you might be able to give.

also, i know there are shorter ways of writing some of this, some of which i know and some i don’t. feel free to enlighten me if you can. ( i have searched many places to find the answer to this such as msdn to no avail).

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        public void Main(string[] args)
        {
            // set consolsize to fit text output
            Console.SetWindowSize(150, 50);
            // creat test text file
            var cd = Directory.GetCurrentDirectory();
            string filetest = Path.Combine(cd + "\\android\\5_tools\\test.txt");
            string brand = (cd + "\\android\\5_tools\\brand.txt");
            string model = (cd + "\\android\\5_tools\\model.txt");
            string sdk = (cd + "\\android\\5_tools\\sdk.txt");
            string amodex = (cd + "\\android\\4_framework\\am.odex");
            string phoneodex = (cd + "\\android\\3_app\\Phone.odex");
            string testapp = (cd + "\\android\\3_app\\test.txt");
            string testframe = (cd + "\\android\\4_framework\\test.txt");

            Console.WriteLine(cd);

            // creating folders to work with
            Directory.CreateDirectory(cd + "\\android");
            Directory.CreateDirectory(cd + "\\android\\1_Compile");
            Directory.CreateDirectory(cd + "\\android\\2_Decompile");
            Directory.CreateDirectory(cd + "\\android\\3_App");
            Directory.CreateDirectory(cd + "\\android\\4_Framework");
            Directory.CreateDirectory(cd + "\\android\\5_tools");
            Directory.CreateDirectory(cd + "\\android\\6_Saved_classes");


            File.WriteAllText(filetest, "DO NOT DELETE!!!! This is a test file to be sure device mounts in RW mode to be sure all commands work");

                // set adb commands
                Process myProcess = new Process();
                myProcess.StartInfo.FileName = "cmd";
                myProcess.StartInfo.RedirectStandardInput = true;
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.Start();
                // running adb commands, and setting up device for transfere to and from
                myProcess.StandardInput.WriteLine("adb kill-server");
                myProcess.StandardInput.WriteLine("adb start-server");
                myProcess.StandardInput.WriteLine("adb shell");
                myProcess.StandardInput.WriteLine("su");
                myProcess.StandardInput.WriteLine("mount -o rw,remount /system");
                myProcess.StandardInput.WriteLine("chmod 777 /system");
                myProcess.StandardInput.WriteLine("chmod 777 /system/framework");
                myProcess.StandardInput.WriteLine("chmod 777 /system/app");
                //getting build props
                myProcess.StandardInput.WriteLine("getprop ro.product.brand > /sdcard/brand.txt");
                myProcess.StandardInput.WriteLine("getprop ro.product.model > /sdcard/model.txt");
                myProcess.StandardInput.WriteLine("getprop ro.build.version.sdk > /sdcard/sdk.txt");
                myProcess.StandardInput.WriteLine("exit");
                myProcess.StandardInput.WriteLine("exit");

                Process myProcess1 = new Process();
                myProcess1.StartInfo.FileName = "cmd";
                myProcess1.StartInfo.RedirectStandardInput = true;
                myProcess1.StartInfo.UseShellExecute = false;
                myProcess1.Start();
                // pulling need files from android
                myProcess1.StandardInput.WriteLine("adb pull /sdcard/brand.txt " + (brand));
                myProcess1.StandardInput.WriteLine("adb pull /sdcard/model.txt " + (model));
                myProcess1.StandardInput.WriteLine("adb pull /sdcard/sdk.txt " + (sdk));
                myProcess1.StandardInput.WriteLine("adb pull /system/app/Phone.odex " + (phoneodex));
                myProcess1.StandardInput.WriteLine("adb pull /system/framework/am.odex " + (amodex));


                //testing mount
                myProcess1.StandardInput.WriteLine("adb push " + (filetest) + " /system/app/test.txt");
                myProcess1.StandardInput.WriteLine("adb push " + (filetest) + " /system/framework/test.txt");
                myProcess1.StandardInput.WriteLine("adb pull /system/app/test.txt " + (testapp));
                myProcess1.StandardInput.WriteLine("adb pull /system/framework/test.txt " + (testframe));


                //Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
                Console.WriteLine(File.Exists(testapp) ? "File exists." : "File does not exist.");
                Console.WriteLine(File.Exists(testframe) ? "File exists." : "File does not exist.");


                //clearing test file
                myProcess1.StandardInput.WriteLine("adb shell");
                myProcess1.StandardInput.WriteLine("su");
                myProcess1.StandardInput.WriteLine("rm /system/app/test.txt");
                myProcess1.StandardInput.WriteLine("rm /system/framework/test.txt");
                myProcess1.StandardInput.WriteLine("exit");
                myProcess1.StandardInput.WriteLine("exit");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(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-04T23:45:54+00:00Added an answer on June 4, 2026 at 11:45 pm

    The program does run in order.

    I suspect your confusion is that you’re launching other programs. By default, the Process class doesn’t wait for myProcess to exit before you start myProcess1. To get this to wait, add a call to Process.WaitForExit():

      myProcess.StandardInput.WriteLine("exit");
    
      // Add a line here!
      // This will cause it to wait until the first process completes
      myProcess.WaitForExit();
    
      Process myProcess1 = new Process();
      myProcess1.StartInfo.FileName = "cmd";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure I'm doing something stupid here, but the following code: ... public void
Probably a stupid question, but here goes. In my view, I have the following
Not sure if im just being stupid or something but here goes i work
I must be missing something stupid here but I can not see it. My
I must be doing something stupid here, because I have some very similar code
With the risk of feeling really really stupid here, but I seem not to
I'm sure I'm just doing something stupid here, but I can't quite figure out
I'm really a starter with Scala, so pardon me if I'm stupid here! I'm
Another stupid question here regarding a SQL scenario. Given data such as: FieldKey DocumentKey
I'm afraid I may be asking a stupid question here, but my google-fu seems

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.