Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly refer to powershell.exe #1

Open
Sleavely opened this issue Aug 6, 2022 · 1 comment
Open

Explicitly refer to powershell.exe #1

Sleavely opened this issue Aug 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Sleavely
Copy link
Owner

Sleavely commented Aug 6, 2022

Running npx win-screenoff in a WSL environment results in an error because the shorthand powershell doesn't exist in PATH. It can probably be solved by explicitly appending .exe to the command:

馃憠 npx win-screenoff
npx: installed 6 in 5.839s
Something went horribly wrong. Do you have Powershell installed? Error: spawn powershell ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn powershell',
  path: 'powershell',
  spawnargs: [
    '-NoProfile',
    '-Command',
    '& {\n' +
      "    Add-Type -TypeDefinition '\n" +
      '    using System;\n' +
      '    using System.Runtime.InteropServices;\n' +
      '\n' +
      '    namespace Utilities {\n' +
      '      public static class Display\n' +
      '      {\n' +
      '          [DllImport("user32.dll", CharSet = CharSet.Auto)]\n' +
      '          private static extern IntPtr SendMessage(\n' +
      '            IntPtr hWnd,\n' +
      '            UInt32 Msg,\n' +
      '            IntPtr wParam,\n' +
      '            IntPtr lParam\n' +
      '          );\n' +
      '\n' +
      '          public static void PowerOff ()\n' +
      '          {\n' +
      '            SendMessage(\n' +
      '                (IntPtr)0xffff, // HWND_BROADCAST\n' +
      '                0x0112,         // WM_SYSCOMMAND\n' +
      '                (IntPtr)0xf170, // SC_MONITORPOWER\n' +
      '                (IntPtr)0x0002  // POWER_OFF\n' +
      '            );\n' +
      '          }\n' +
      '      }\n' +
      '    }\n' +
      "    '\n" +
      '    [Utilities.Display]::PowerOff()\n' +
      '    }'
  ]
}
@Sleavely Sleavely added the bug Something isn't working label Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant