[SOLVED] What is the easiest why to have a program run when another program is being started?

Richard_268

Honorable
Jul 6, 2017
35
0
10,540
What is the easiest why to have a program run when another program is being started? For example, running CS:GO and have Spotify automatically run without having to run Spotify every time I want to run CS:GO.

Also, is there a way to automatically close the same program when the main program is being closed?
 
Solution
FYI - Reference:

NAME
Start-Process
SYNOPSIS
Starts one or more processes on the local computer.

SYNTAX
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]>] [-Credential <PSCredential>] [-LoadUserProfile]
[-NoNewWindow] [-PassThru] [-RedirectStandardError <String>] [-RedirectStandardInput <String>]
[-RedirectStandardOutput <String>] [-UseNewEnvironment] [-Wait] [-WindowStyle {Normal | Hidden | Minimized |
Maximized}] [-WorkingDirectory <String>] [<CommonParameters>]
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]>] [-PassThru] [-Verb <String>] [-Wait] [-WindowStyle
{Normal | Hidden | Minimized | Maximized}] [-WorkingDirectory <String>] [<CommonParameters>]

DESCRIPTION
The...

Ralston18

Titan
Moderator
You could create a desktop shortcut link that launches a DOS .bat file or a Powershell script.

Likewise another icon to close.

Closing may be a bit trickier if there needs to be a test to check if one app must be/has been closed first if that is indeed the case.

Otherwise both can just be directly closed one after the other in whatever order you wish.
 

Ralston18

Titan
Moderator
FYI - Reference:

NAME
Start-Process
SYNOPSIS
Starts one or more processes on the local computer.

SYNTAX
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]>] [-Credential <PSCredential>] [-LoadUserProfile]
[-NoNewWindow] [-PassThru] [-RedirectStandardError <String>] [-RedirectStandardInput <String>]
[-RedirectStandardOutput <String>] [-UseNewEnvironment] [-Wait] [-WindowStyle {Normal | Hidden | Minimized |
Maximized}] [-WorkingDirectory <String>] [<CommonParameters>]
Start-Process [-FilePath] <String> [[-ArgumentList] <String[]>] [-PassThru] [-Verb <String>] [-Wait] [-WindowStyle
{Normal | Hidden | Minimized | Maximized}] [-WorkingDirectory <String>] [<CommonParameters>]

DESCRIPTION
The Start-Process cmdlet starts one or more processes on the local computer. To specify the program that runs in
the process, enter an executable file or script file, or a file that can be opened by using a program on the
computer. If you specify a non-executable file, Start-Process starts the program that is associated with the file,
similar to the Invoke-Item cmdlet.
You can use the parameters of Start-Process to specify options, such as loading a user profile, starting the
process in a new window, or using alternate credentials.

RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821638
Debug-Process
Get-Process
Start-Service
Stop-Process
Wait-Process
REMARKS
To see the examples, type: "get-help Start-Process -examples".
For more information, type: "get-help Start-Process -detailed".
For technical information, type: "get-help Start-Process -full".
For online help, type: "get-help Start-Process -online"
 
Solution