Creating a batch file to launch the currently opened applications and folders

Posted on

QUESTION :

Example: If I were viewing example.txt in a Notepad and editing an image in GIMP, I’d like to generate a batch file that would launch those files using those applications after I’ve closed the windows. Is there a way to create a launcher like this without manually copying and pasting the names of open files and applications into a batch file or shell script?

ANSWER :

Yes, you can, if you use PowerShell etc.

Use

get-process | select name

this will get a list of process names

Now you can find the commandline for the process names you interested in with the following

gwmi win32_process -filter "name=$processname'" | select commandLine

Now you can use PowerShell to create shortcuts

You can create a simple script do what you want, as there are other things you may want to add for the shortcuts other than the commandline (which is your target in the shortcut) and process name.

Leave a Reply

Your email address will not be published.