How can i bring an application to the front with a batch-script in WinXP

Like if it's no open, start the application otherwise bring the application to the front. I already have this script but i need it to bring it to the front:

@echo off
tasklist /FI "IMAGENAME eq TOTALCMD.exe" | find /i "TOTALCMD.exe"
IF ERRORLEVEL 1 start "" "C:\totalcmd\TOTALCMD.exe

cheers && thx noircc

1 Answer

From this topic on Stack Overflow you've got 3 options.

I wouldn't use the options of CMDOW or NirCmd from NirSoft because most virusscanners will trip over those utilities so you are left with 1 option:

I would use AutoHotkey or AutoIt.

To bring a window to the front in AutoHotkey you could use its title:

WinRestore, Untitled - Notepad
WinActivate Untitled - Notepad

You could also follow the script on this page and code everything in AutoHotkey without the need for a batchfile. That way you could use the .exe-filename.


But if this is to code TOTALCMD.exe to only run once...
It does have an option to only allow 1 copy at a time

When selected if you run a second copy the first will become active.

enter image description here

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like