Task : Launch X after application after Y launched

unko

New member
Member
VIP
Local time
9:50 AM
Messages
289
Task : Launch X app after Y app started, close X after Y stops

Hello, i use CPU Throttle while gaming/encoding, and i'd like it be launched automatically after i launch a bunch of specific .exe ; how can i set that? Hope someone will help. Thanks.
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Win7x64
bump?
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
You may need to write a batch file or script.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
n/a
OS
W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
CPU
AMD Phenom II x6 1100T, 3.3 GHz
Motherboard
ASUS M4A88T-M/USB3 (AM3)
Memory
12GB DDR3 1333 G-Skill (4GB x 2), G-Skill (2GB x 2)
Graphics Card(s)
NVIDIA GeForce GTX 660
Sound Card
Realtek?
Monitor(s) Displays
Samsung S23B350
Screen Resolution
1920x1080
Hard Drives
WD Green 2TB (SATA), WD Green 3TB (SATA), WD Blue 4TB (SATA), WD Blue 6TB (SATA)
PSU
Cooler Master
Case
Antec GX300 Tower
Cooling
3x Antec TRICOOL 120mm Fans
Mouse
Wired Optical
Internet Speed
DSL
Antivirus
Avast
Browser
Pale Moon (64 bit)
Other Info
2018-12-27 Upgraded HDDs
2015-12-10 Upgraded case, graphics card, storage
2015-08-15 Upgraded motherboard & RAM
2015-07-15 Upgraded LM17.1 to LM17.2
Sorry for the latery. Ok need script but how i do that? Like a bat..?

Forgot to say : That app (CPUThrottle) should close after game/encoding is closed..
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
You could use a bat file, PowerShell or VB script.

I'll ask Brink to ask one of SevenForums' script experts to visit this thread.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
n/a
OS
W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
CPU
AMD Phenom II x6 1100T, 3.3 GHz
Motherboard
ASUS M4A88T-M/USB3 (AM3)
Memory
12GB DDR3 1333 G-Skill (4GB x 2), G-Skill (2GB x 2)
Graphics Card(s)
NVIDIA GeForce GTX 660
Sound Card
Realtek?
Monitor(s) Displays
Samsung S23B350
Screen Resolution
1920x1080
Hard Drives
WD Green 2TB (SATA), WD Green 3TB (SATA), WD Blue 4TB (SATA), WD Blue 6TB (SATA)
PSU
Cooler Master
Case
Antec GX300 Tower
Cooling
3x Antec TRICOOL 120mm Fans
Mouse
Wired Optical
Internet Speed
DSL
Antivirus
Avast
Browser
Pale Moon (64 bit)
Other Info
2018-12-27 Upgraded HDDs
2015-12-10 Upgraded case, graphics card, storage
2015-08-15 Upgraded motherboard & RAM
2015-07-15 Upgraded LM17.1 to LM17.2
I have placed a request for assistance, so hopefully an expert will show up and assist you with your problem.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
n/a
OS
W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
CPU
AMD Phenom II x6 1100T, 3.3 GHz
Motherboard
ASUS M4A88T-M/USB3 (AM3)
Memory
12GB DDR3 1333 G-Skill (4GB x 2), G-Skill (2GB x 2)
Graphics Card(s)
NVIDIA GeForce GTX 660
Sound Card
Realtek?
Monitor(s) Displays
Samsung S23B350
Screen Resolution
1920x1080
Hard Drives
WD Green 2TB (SATA), WD Green 3TB (SATA), WD Blue 4TB (SATA), WD Blue 6TB (SATA)
PSU
Cooler Master
Case
Antec GX300 Tower
Cooling
3x Antec TRICOOL 120mm Fans
Mouse
Wired Optical
Internet Speed
DSL
Antivirus
Avast
Browser
Pale Moon (64 bit)
Other Info
2018-12-27 Upgraded HDDs
2015-12-10 Upgraded case, graphics card, storage
2015-08-15 Upgraded motherboard & RAM
2015-07-15 Upgraded LM17.1 to LM17.2
I'm waiting then, thank you!
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
Basically, use a text editor like Notepad and put the commands separated by "ping" command to get a delay between each launch. The number after the "-n" is the approximate seconds delay. For example:

MyLauncher.cmd with a 5 second delay between each launch might contain these lines

notepad.exe MyLauncher.cmd
ping -n 5 127.0.0.1 >nul
iexplore.exe www.sevenforums.com
ping -n 5 127.0.0.1 >nul
(some other program yadda yadda)


you get the idea. Make sure each command has the complete path to the exe with all params needed.
You can find more elaborate graphics based delay lauch tools on freeware sites. But this should work for simple needs.
 

My Computer

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
You should make a list of all the programs and services that are involved and a description of exactly what you want to happen.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
n/a
OS
W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
CPU
AMD Phenom II x6 1100T, 3.3 GHz
Motherboard
ASUS M4A88T-M/USB3 (AM3)
Memory
12GB DDR3 1333 G-Skill (4GB x 2), G-Skill (2GB x 2)
Graphics Card(s)
NVIDIA GeForce GTX 660
Sound Card
Realtek?
Monitor(s) Displays
Samsung S23B350
Screen Resolution
1920x1080
Hard Drives
WD Green 2TB (SATA), WD Green 3TB (SATA), WD Blue 4TB (SATA), WD Blue 6TB (SATA)
PSU
Cooler Master
Case
Antec GX300 Tower
Cooling
3x Antec TRICOOL 120mm Fans
Mouse
Wired Optical
Internet Speed
DSL
Antivirus
Avast
Browser
Pale Moon (64 bit)
Other Info
2018-12-27 Upgraded HDDs
2015-12-10 Upgraded case, graphics card, storage
2015-08-15 Upgraded motherboard & RAM
2015-07-15 Upgraded LM17.1 to LM17.2
Anytime i launch a game, i want CPU Throttle to launch. And when i close that game, i want it to close too! Not sure to understand what MilesAhead offered, i thought i'll have a to make a new shortcut for each game so it'll launch CPU Throttle at same time. But no, that's not gonna do it. Really need a script that's always running and monitoring, automatically launched at boot.
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
I will play with this a bit later, but here's my idea if someone wants to give it a try already:
  • Create a PowerShell script
  • Start first program:
    • Code:
      [System.Diagnostics.Process]::Start("Program_1").WaitForExit(5000)
    • Wait for Exit delay is set for 5 seconds (5,000 milliseconds); if the Program_1 is not closed within this time frame, executing the script continues. This will give the Program_1 some time to completely start before Program_2 is launched, increase the value if 5 seconds is not enough
  • Start Program_2, this time with Wait for Exit switch with no value:
    • Code:
      [System.Diagnostics.Process]::Start("Program_2").WaitForExit()
    • The Wait for Exit switch without a value causes the script to halt and wait until the Program_2 is closed
  • Now kill first task (program) with Taskkill
Should work.

Kari
 
Last edited:

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
OK, here's the PowerShell script, delay between launch of Program_1 and Program_2 set to 10 seconds (10,000 milliseconds). Use Notepad or other text editor to write the script, save it with .ps1 extension, for instance F:\Scripts\MyScript.ps1.

The instructions might look complicated but this really is quite fast and easy.

This script would work as follows:
  • Start Program 1
  • Wait given time, in this example 10 seconds
  • Start Program 2
  • When Program 2 is manually closed, close Program 1
  • Exit PowerShell
1. The script:
Code:
[System.Diagnostics.Process]::Start("[hl]Path_to_Program_1[/hl]").WaitForExit(10000)
[System.Diagnostics.Process]::Start("[hl]Path_to_Program_2[/hl]").WaitForExit()
taskkill /IM [hl]Name_of_the_process_Program_1[/hl]
exit
Highlighted parts:
  • Lines 1 and 2:
    Name and path of Programs 1 & 2, for instance C:\Windows\System32\notepad.exe or D:\Games\MyGame\Rally.exe
  • Line 3:
    Process (image) name for process (program) 1, for example notepad.exe. The second process needs no Taskkill as Program_2 is already manually closed for the script to continue.
2. Change PowerShell Script Execution Policy:

Before running the script you have to change the PowerShell Execution Policy. This must be done only once, any change in policy will be active until the next time you decide to change it. By default the policy is set to Restricted, meaning no scripts are allowed to run.

To do this run PowerShell elevated (as administrator) and change the policy as told here:
  • Click Start
  • Type PowerShell to Start Menu Search field
  • Right click PowerShell
  • Select Run as administrator
    2013-08-07_140151.PNG
  • Accept the UAC prompt by clicking Yes
  • Type the following command to PowerShell, press Enter:
    Set-ExecutionPolicy Unrestricted
  • Accept the policy change by typing Y, press Enter
    2013-08-07_140406.PNG
The policy is now changed, you can close the elevated PowerShell window and continue from below.

3. Run the script:
  • Save the script with .ps1 extension, for instance F:\Scripts\MyScript.ps1
  • Now simply run the script using Run dialog (WIN + R) giving the following command or create a shortcut for this command:
    powershell.exe F:\Scripts\MyScript.ps1
Notice please: If the launch of the Program_2 does not need to wait until the Program_1 has completely started, leave the Wait for Exit switch away from first line. In this case the script would be:
Code:
[System.Diagnostics.Process]::Start("Path_to_Program_1")
[System.Diagnostics.Process]::Start("Path_to_Program_2").WaitForExit()
taskkill /IM Name_of_the_process_Program_1
exit
That's it.

Kari
 
Last edited:

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
Thanks I'm going to try it but I see a problem, you wrote when program 2 is closed, program 1 will close, right? It's the opposite, since program 1 is the game, that's this one I'll close manually...
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
Thanks I'm going to try it but I see a problem, you wrote when program 2 is closed, program 1 will close, right? It's the opposite, since program 1 is the game, that's this one I'll close manually...
I really cannot see what's the issue? The same script, now using CPU Throttle and Game as example programs:
Code:
[System.Diagnostics.Process]::Start("Path_to_CPU Throttle")
[System.Diagnostics.Process]::Start("Path_to_Game").WaitForExit()
taskkill /IM Name_of_the_process_CPU Throttle
exit
That's it. CPU Throttle and the Game are launched. When the Game is manually closed, system stops the CPU Throttle. Exactly what you wanted:
Anytime i launch a game, i want CPU Throttle to launch. And when i close that game, i want it to close too!

About one of your requirements:
Really need a script that's always running and monitoring, automatically launched at boot.
This is absolutely unnecessary. The script I have given to you launches both CPU Throttle and the Game, then closes CPU Throttle when the Game is manually closed.

Kari

Kari
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
I just tried to launch it but got error, checked and it says "use of script is disabled on this system". Also .PS1 extension is by another app (PSXMemTool) but i guess that's not important. There's something i'm not sure of still though : When you launch this script, it'll automatically launch both of the apps and close the one of your choice in the end, right?

If so that means i would have to create a script for each games? That's not what i asked first. I wanted a script to run all the time, monitoring all process, so as soon as it detect i launched one of the exe from a list (games), it'll launch CPU Throttle, and when closing a game from that list, close CPU Throttle. But maybe that's not possible..? I have no knowledge for those things. You tell me. Thanks!
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
I just tried to launch it but got error, checked and it says "use of script is disabled on this system". Also .PS1 extension is by another app (PSXMemTool) but i guess that's not important. There's something i'm not sure of still though : When you launch this script, it'll automatically launch both of the apps and close the one of your choice in the end, right?
Right.

I forgot to mention that scripts must first be enabled. As I always enable the PowerShell scripts I simply forgot the whole thing.

I am not at home now, please give me an hour or two and I will edit my original post accordingly to show how to enable scripting. In the mean time, here's something for you to read:

If so that means i would have to create a script for each games? That's not what i asked first. I wanted a script to run all the time, monitoring all process, so as soon as it detect i launched one of the exe from a list (games), it'll launch CPU Throttle, and when closing a game from that list, close CPU Throttle. But maybe that's not possible..? I have no knowledge for those things. You tell me. Thanks!
With native Windows batch and scripting tools, to achieve what you want to is impossible, as far as I know. In my opinion the better alternative is to prepare shortcuts for each game, each shortcut launching a script that starts CPU Throttle and the respective game, then closes CPU Throttle when the game is closed.

Kari
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
OK, the original post is now more like a mini tutorial, it is edited to cover everything you need to know to enable PowerShell scripts and create a script that launches multiple programs and closes them all when the last program launched by the script is manually closed.

Kari
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
If so that means i would have to create a script for each games? That's not what i asked first. I wanted a script to run all the time, monitoring all process, so as soon as it detect i launched one of the exe from a list (games), it'll launch CPU Throttle, and when closing a game from that list, close CPU Throttle. But maybe that's not possible..? I have no knowledge for those things. You tell me. Thanks!
With native Windows batch and scripting tools, to achieve what you want to is impossible, as far as I know. In my opinion the better alternative is to prepare shortcuts for each game, each shortcut launching a script that starts CPU Throttle and the respective game, then closes CPU Throttle when the game is closed.

Kari
Hmm ok well thanks for all, i'll have a look into it, and if someone knows a way to do the full thing i wanted, let us know. I guess it would be an app doing that then, not a script.
 

My Computer

Computer type
PC/Desktop
OS
Win7x64

My Computer

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Link's dead ands I cannot find it anywhere else :( Looked good..
 

My Computer

Computer type
PC/Desktop
OS
Win7x64
Back
Top