Turning on QuickEdit from a program (CLI/C#)

  • Context: C# 
  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Program Turning
Click For Summary
SUMMARY

This discussion focuses on launching a program with QuickEdit enabled and setting its priority to BelowNormal using C#. The provided code snippets demonstrate how to start a process with BelowNormal priority and how to initiate a program via a shortcut (.lnk) file. However, the challenge lies in combining both functionalities, as setting the priority on the shortcut affects the shortcut itself rather than the spawned process. The conversation suggests reading the .lnk file contents to execute the command directly or finding the process ID (PID) after starting the program to modify its settings.

PREREQUISITES
  • Understanding of C# Process class
  • Familiarity with ProcessPriorityClass enumeration
  • Knowledge of Windows shortcut (.lnk) file structure
  • Experience with process management in Windows
NEXT STEPS
  • Learn how to read and parse .lnk files in C#
  • Research methods to retrieve and modify process settings using PID
  • Explore the use of Windows API for process manipulation
  • Investigate alternative ways to enable QuickEdit in console applications
USEFUL FOR

Developers working with C# who need to manage process priorities and console settings, particularly those interested in enhancing user interaction with command-line applications.

CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
0
I'm trying to run a program, turn on QuickEdit (click-and-drag to copy, right-click to paste), and set the priority to BelowNormal.

The following will start a program at BelowNormal priority:
Code:
Process pr = new Process();
pr.StartInfo.FileName = "blah.exe";
pr.Start();
pr.PriorityClass = ProcessPriorityClass.BelowNormal;

The following will start a program with QuickEdit, assuming the shortcut is set up appropriately:
Code:
Process pr = new Process();
pr.StartInfo.FileName = "blah.lnk";
pr.Start();

But I can't find a way to do both. If I set the priority on the second, it sets it for the shortcut -- not the spawned process. (Not that I'm quick enough to grab it before it disappears, usually.)

Thoughts?
 
Technology news on Phys.org
My guess is that running the link just causes explorer to run the program and then return - so the process you are getting back is the explorer instance.
Can you read the contents of the .lnk and run the command yourself ?
Otherwise you are going to have to find the PID of the process once it has started and then attach to it

There used to be a similair problem running command line apps with system() - they would inherit the environment of the calling program so sometimes you had to run them with system("cmd appname.exe")
 
mgb_phys said:
Can you read the contents of the .lnk and run the command yourself ?

I would be setting up the .lnk file for the purpose of the program, so that's not an issue. .lnk files let me choose settings like display types and QuickEdit, which are useful to me here.

The program I'm working on just spawns a bunch of windows with different settings. In this case, (say) 8 instances of Pari running a program over similar settings. But I'd like to turn on QuickEdit since I may end up using some of the windows manually.

mgb_phys said:
Otherwise you are going to have to find the PID of the process once it has started and then attach to it

Yeah, I guess so. But once I do, how can I change the setting?
 

Similar threads

  • · Replies 29 ·
Replies
29
Views
9K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K