1.

Solve : Getting multiple lines of output as arguments to another program??

Answer»

Hi, I have an Acer laptop, running windows 7, etc.

My question is about obtaining a certain result in windows command prompt, either through a batch FILE or (preferably) through a single command.

What I'd like to do is take every line of output from ONE command and use each line as an argument for SEPARATE calls to another command.

Specifically, I'd like to take each line of output from this command:

powercfg -devicequery wake_armed

... and use each of the devices named (each appearing on a new line) as the last argument to this command:

powercfg -devicedisablewake

There are some troubles:

1. seems to require the string of the device's name to be placed in double-quotes in order to work, but that's not how powercfg outputs the devices -- it outputs each one as a string on a new line.

2. powercfg's help doesn't accept multiple devices being wake-disarmed at the same time, requiring some way of REPEATEDLY calling powercfg for each device needing disabling.

The purpose, of course, is to disable all wake-armed devices with "one click".

Can anybody explain to me what I'll need to do to obtain this result? Is it even possible to do this with some kind of command shorthand, through piping output, or will a batch file be absolutely required?

-- eyenottry
Code: [Select]for /f "delims=" %%A in ('powercfg -devicequery wake_armed') do (
powercfg -devicedisablewake %%A
timeout /t 1 >nul
)

I believe this is what you want. if it doesn't work, can you post the output of 'powercfg -devicequery wake_armed' for US?From prompt... in a batch use double percent signs (batch: %%A prompt: %A)

Demo mode; remove @echo to make it operate for real

C:\>for /f "delims=" %A in ('powercfg -devicequery wake_armed') do @echo powercfg -devicedisableawake "%A"
powercfg -devicedisableawake "NVIDIA nForce 10/100/1000 Mbps Networking Controller "
powercfg -devicedisableawake "Microsoft USB IntelliMouse Optical (002)"
powercfg -devicedisableawake "HID Keyboard Device (001)"



Discussion

No Comment Found