Skip to content

Commit

Permalink
Replace deprecated WMIC
Browse files Browse the repository at this point in the history
WMIC is deprecated, even removed in Windows 11 dev builds.  Replace its usage with powershell `Get-CimInstance`
  • Loading branch information
Nerdsie committed Nov 23, 2021
1 parent 8c8c487 commit 14b6db1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/util/RiotConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ export default class RiotConnector extends EventEmitter {
* Get command based on platform.
*/
const command: string = IS_WIN
? `WMIC PROCESS WHERE name='${RIOTCLIENT_PROCESS}' GET CommandLine`
? `(Get-CimInstance Win32_Process -Filter "name = '${RIOTCLIENT_PROCESS}'").CommandLine`
: `ps x -o command= | grep '${RIOTCLIENT_PROCESS}'`;

/**
* Get options for exec based on platform.
*/
const execOptions: { shell?: string } = IS_WIN
? { shell: `powershell` }
: {};

/**
* Execute the command
*/
exec(command, (error, stdout, stderr) => {
exec(command, execOptions, (error, stdout, stderr) => {
if (error || !stdout || stderr) {
return;
}
Expand All @@ -83,7 +90,7 @@ export default class RiotConnector extends EventEmitter {
/**
* If Windows we need to slightly adjust.
*/
if (IS_WIN) normalizedPath = normalizedPath.split(/\n|\n\r/)[1];
if (IS_WIN) normalizedPath = normalizedPath.split(/[\n\r]/).join(" ");

const match: RegExpMatchArray = normalizedPath.match(
'"--priority-launch-path=(.*?)"'
Expand Down

0 comments on commit 14b6db1

Please sign in to comment.