Unable to redirect command line output

Hi,

I am trying to redirect the command line output to a text file. Whenever I am running the below command I am getting an exit code 1. The output text file is getting created, however it does not contain the output. Basically it is blank file.
Need help to solve this.

waithidden cmd.exe /C bcdedit >C:\Temp\output.txt

image

That can get confusing whether to redirect the output of bcdedit, or of cmd.exe itself. Try

waithidden cmd.exe /C ""bcdedit" >C:\Temp\output.txt 2>&1"

1 Like

Thanks for the response Jason!

I tried the said command but it is not working. Getting below message in output text file

‘“bcdedit”’ is not recognized as an internal or external command,
operable program or batch file.

Two things to check - the most likely is that there isnt a 32-bit bcdedit, and you need to switch the action into 64-bit mode using
action uses wow64 redirection false
Anywhere in the script before the waithidden command.

Otherwise, you may be missing a %PATH% for the LocalSystem account (much more rare but did encounter someone configured like that a couple weeks ago).

1 Like

Hey Thanks Jason!! It works.

Now I am able to redirect the output to a text file.

action uses wow64 redirection false
waithidden cmd.exe /C ““bcdedit” >C:\Temp\output.txt 2>&1”

1 Like

Hi Jason,

Sorry for the late post.

Just want to understand why we use wow64 redirection false action. Also I would like to understand when can we use this wow64 redirection.

If you leave wow64 redirection enabled, any process the BESClient spawns will behave in 32-bit mode - a call to “Program Files” is redirected to “Program Files (x86)” , and a call to “\Windows\System32” is directed to “\Windows\Syswow64”, and “HKLM\Software” goes to “HKLM\Software\Wow6432Node”.

Any time you want to use a program in 64-bit “native” mode, disable wow64 redirection.

The reason to keep wow64 redirection, would be backward compatibility with 32-bit packages that reference paths and depend upon the path redirection.

1 Like