- 1 year ago
Application run using RunOnce registry key does not start when logged in using Enter-PSSession
The issue you're describing may be related to the fact that the RunOnce
registry key runs an application only once and then removes the entry from the registry. When you log in using Enter-PSSession
, the registry key may have already been executed, and therefore the application will not run again.
To work around this issue, you can try setting the RunOnce
registry key to run the application every time the computer starts up. Here's an example:
Open the Registry Editor by pressing the Windows key + R and typing
regedit
, then pressing Enter.Navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
Create a new string value with a name that describes the application, such as
MyApp
.Double-click the new value to open the Edit String dialog box.
In the Value data field, enter the command that starts the application, including any necessary parameters. For example, you might enter
C:\MyApp\MyApp.exe
.Click OK to save the changes and close the dialog box.
Exit the Registry Editor.
Once you've set the RunOnce
registry key to run the application every time the computer starts up, you should be able to run the application even when logged in using Enter-PSSession
. Note that this approach will cause the application to start automatically every time the computer starts up, so you may want to remove the registry key when you no longer need to run the application automatically.