1

The following code will launch notepad.exe which can be seen in the processes. But it does not launch the notepad on the screen.

$wmi = [WMIClass]"\\REMOTE_MACHINE_NAME\root\cimv2:Win32_Process" $result = $wmi.Create("notepad.exe", $null, $null) 

The following code also launches the notepad on the remote machine for a specified duration but it is not visible.

Invoke-Command -ComputerName "REMOTE_MACHINE" -Credential $cred -ScriptBlock { Start-Process "C:\Windows\System32\Notepad.exe" Start-Sleep -Seconds 15 Get-Process -Name "Notepad" #-ErrorAction SilentlyContinue Get-Process | Where-Object {$_.Name -Like 'Note*'} } 

How to achieve this? I do not want to use PSEXEC for security reasons.

4
  • 3
    If you connect remote into another computer this session does not have a GUI on the remote computer - it is invisible. What is it what you actually want to achieve? Commented Aug 5 at 10:49
  • It's meant for security not to have system processes on the desktop. Sysinternals psexec might be able to do it, if it's really necessary. Commented Aug 5 at 14:12
  • 2
    So you need to connect to the active user session... but which one? A Windows computer can actually have many or even zero active user sessions. That a PC seems to typically only have one active session is an accident of how things are provided out of the box and how we tend to use it (and an artificial limitation specifically in Home Edition and the various S Mode/RT/SE/IoT reduced editions), but not a limitation of the OS itself. If there are many sessions, how will know which one you need? Commented Aug 6 at 3:10
  • 3
    If you need a process to be visible in a particular user's logon session, 99.9% of the time it is easier to simply start the process from that machine as that user. Commented Aug 6 at 13:04

1 Answer 1

-1

if you need a process in an active user session, but you want to run it remotely, then you will have to use a bundle of scheduler and events. You will need to create a task separately in the task scheduler, so that the task always runs in an active user session. Set events as a trigger and you can set up a filter for a keyword. Next, you will only need to remotely trigger the event/log entry.

Sign up to request clarification or add additional context in comments.

1 Comment

Please provide some executable code in your answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.