2

I'm working on a little something and i need to 'simplify' a windows operation and i'm kinda stuck, i don't know if you guys can help me figure it out here.. so here's my problem and how i want it to be solved:

I need to be able to suspend a specific windows process for X seconds at the press of 1 or 2 buttons. Ideally one button to suspend it with a X seconds delay before it resumes, but could be 1 button to suspend it and another 1 to resume it.

What i expect it to be (then agian, could be a little different): create a .exe file and bind the file shortcut to a programmable button on one of my macro button on my keyboard. I need help to figure out a way to code this into something.. i tried to use a tool called pssuspend.exe but i couldn't get it to work.

Thanks for the help !

6
  • Without too much work and as a basic solution you can create a shortcut file to your pssuspend.exe, then edit the properties of it to add the process name to suspend as a parameter in the "Target" field. You can bind a shortcut key combo and set if it is to run minimised for example. You could do the same again for the resume. Can you suspend the process you have in mind without elevating? Dec 28, 2017 at 19:32
  • Thanks for the reply. But i can't figure out how to edit the properties of this .exe ? any hints ? Also, i'd like it to work while using another full screen application without the need of minimizing it. Dec 29, 2017 at 0:27
  • You create a shortcut to it and edit the properties of that. Dec 29, 2017 at 8:39
  • Thanks again for the reply sir ! It seems to work when I click on my shortcut, it runs pssuspend with the correct arguments, but the new issue is that when I assign the macro key of my keyboard to this shortcut, it will ignore all arguments and only open the basic file without the custom arguments.. is there a workaround? Is there a way to create some sort of BAT file to help me ? Dec 29, 2017 at 12:39
  • In that case, what about a little exe wrapper: Download and install AutoIt (autoitscript.com/site/autoit). Create a new text file, give it the name "suspend.au3". Add the 3 lines: Run("C:\SysinternalsSuite\pssuspend.exe onedrive", "", @SW_HIDE) Sleep(5000) Run("C:\SysinternalsSuite\pssuspend.exe onedrive -r", "", @SW_HIDE) Adjust the process as required from onedrive above. You can save and then right click and choose "Complie Script (x86)". This will generate you an exe. Adjust it you want to sleep (e.g. 3 secs) and unsuspend, create an exe for each task etc. Dec 29, 2017 at 13:04

3 Answers 3

2

I stumbled upon this question looking to find a solution that would specifically apply to Grand Theft Auto Online. Its a long known "workaround" that you can play a solo online session for a short period of time by suspending the gta5 process in Windows Resource Monitor for around 5-10 seconds and then resuming. If anyone is also looking for an easy PowerShell script to quicken this process, here's how I used PsychoX's answer to put together something easy to run from a shortcut:

#Download PsSuspend from Microsoft
#https://docs.microsoft.com/en-us/sysinternals/downloads/pssuspend
#Set below path to where you unzipped PsSuspend
$PATH = "C:\Users\User\Directory\PSTools\"

cd $PATH
.\pssuspend.exe gta5
Start-Sleep -s 10
.\pssuspend.exe gta5 -r
EXIT

Make sure to update the $PATH variable to where you unzipped PsSuspend. I found setting Start-Sleep -s to 5 was far too short, 10 seems to work every time but modify as needed to suspend any process for a specific amount of time and then resume. From here, you could save this as a PowerShell script, and execute from a shortcut. Just make sure you're PowerShell execution policy is configured correctly via Set-ExecutionPolicy.

This is probably the quickest and plenty dirty way to accomplish the original ask.

1
  • This is exactly what I was looking for, executable included. Thank you
    – mrbolichi
    Aug 28, 2020 at 19:49
1

Google search feed for 15 September 2018:

PsSuspend tool from PsTools (Microsoft sysinternals utilities pack)

Since this is some kind official tool, it may be the best choice for simple scripts and automation.

Running PsSuspend with a process ID directs it to suspend or resume the process of that ID on the local computer. If you specify a process name PsSuspend will suspend or resume all processes that have that name. Specify the -r switch to resume suspended processes.

Usage: pssuspend [- ] [-r] [\\computer [-u username] [-p password]] <process name | process id>

Simple program using Windows API: SuspendThread and ReasumeThread

Windows has some functions realated to suspending and reasuming threads (so process some kind alos). The kernel32.dll library provides SuspendThread and ReasumeThread. Warning! There also are 64-bit counterparts for this functions Wow64SuspendThread and Wow64ResumeThread (which doesn't have official documentation).

There is nice, small application that uses that technique also version in C/C++ also on CodeProject (source code available).

Usage: pausep PID [/r] (/r switch reasumes the process).

There is version in C# .NET also on CodeProject.

Also look at this Stackoverflow answer

More user-friendly, command line (Powershell) method from that answer:

As I said Windows command line has not any utility to do that but you can invoke a Windows API function from PowerShell. First install Invoke-WindowsApi script then you can write this:

Invoke-WindowsApi "kernel32" ([bool]) "DebugActiveProcess" @([int]) @(process_id_here)

Similar technique was used to create this PowerScript script created for process pausing.

0

I write this to replace PsSuspend for my use case. (not full PsSusend features are included)

https://github.com/craftwar/suspend

It supports unicode and multiple target processes.
You don't need run PsSuspend multiple times to suspend multiple processes. (It's very slow)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .