Pass Front for Windows XP Command Shell

Is there a command that I can put in a .bat file for Windows XP to bring the command shell to the fore?

+5
source share
6 answers

No from the batch file. If you want to activate the window, you must use SetActiveWindow () . If you don't want to get dirty while programming windows, but still want to activate windows and simple things, I recommend checking Autoit . You can always call this program from your batch file so that it performs this task.

+2
source

nircmd , .

nircmd win activate "titleofwindow"

cmd, ( TITLE )

:

TITLE %SOME_UNIQUE_VALE%
nircmd win activate %SOME_UNIQUE_VALE%

.

, NirCmd ( , ), .

+8

cmd - file1.bat , file2.bat, exit.

file1.bat

....
[your code here]
start C:\file2.bat
exit

file1.bat .bat , . .bat

+2

CMDOW DOS, . . , - CMDOW , . . CMDOW , , - , , -, - -.

+1

, #, Window. .

using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using  System.Runtime.InteropServices; 

 namespace ConsoleApplication1
 {
    class Program
    {

        [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
        public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);

        [DllImport("USER32.DLL")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);
        [DllImport("User32.dll")]
        private static extern bool IsIconic(IntPtr handle);
        [DllImport("User32.dll")]
        private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
        const int SW_RESTORE = 9;
        public static void bringToFront(string title)
        {
            // Get a handle to the Calculator application.
            IntPtr handle = FindWindow(null, title);

            // Verify that Calculator is a running process.
            if (handle == IntPtr.Zero)
            {
                return;
            }
            if (IsIconic(handle))
            {
                ShowWindow(handle, SW_RESTORE);
            }

            Console.WriteLine("Founded ");
            SetForegroundWindow(handle);

        }

        static void Main(string[] args)
        {

            if (args.Length > 0)
                bringToFront(args[0]);
            else
                Console.WriteLine("specify program window title");

        }
    }
}

script -

/FI "IMAGENAME eq program.exe" | "program.exe" if errorlevel 1 (program.exe) else (BringToFront.exe " " )

0

- Ctrl + Shift + Esc, . , , Enter.

-3

All Articles