Sign in to follow this  
Followers 0
Sn3akyP3t3

How to ShellExecute output redirect?

4 posts in this topic

I've done output redirect with the run command, but it looks sloppy and difficult to deal with adding variables and macros to the command. This would be an example.

RunWait(@ComSpec & " /c ping.exe www.google.com>""%TEMP%/pingResults.log""", @SystemDir, @SW_HIDE)

Why doesn't something similar to this work? Note this command requires the devcon executable from Micro$oft which is free for download.

ShellExecute(@ScriptDir & "\devcon\i386\devcon.exe", 'hwids "*" > "' & @ScriptDir & '\DevconOutput.txt"')

The devcon script above runs, but does not follow the expected redirect which puzzles me.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would suspect that the output redirection is handled by @ComSpec / cmd.exe. ShellExecute directly calls devcon.exe, which does not recognize the redirection as a valid input parameter :unsure: ...

Edited by KaFu

Share this post


Link to post
Share on other sites

@KaFu, I believe that is correct, but I'm not sure. I'm used to the fact that if the syntax is not correct then it will fail to run or output an error screen that is too fast to read the output of.

Too bad some applications omit built in print to file or logging options as an alternative for cases like this. Scripting FFMPEG with python was another case that I ran into where my wish list just wasn't answered this year.

I'll try to rewrite it as I had before with the run command until I learn a new trick that doesn't drive me mad with misplaced spaces and quotation marks! :unsure:

Share this post


Link to post
Share on other sites

I thought the temp folder had spaces in the path, but this appears to work. Perhaps it is how Windows interprets the %temp% directive that allows for it. It appears to work also for the @TempDir macro.

RunWait(@ComSpec & ' /c "' & @ScriptDir & '\devcon\i386\devcon.exe" hwids * >%temp%/DevconOutput.txt', @SystemDir, @SW_HIDE)

However, if spaces are clearly in the path then location of the double quote marks is paramount.

RunWait(@ComSpec & ' /c ""' & @ScriptDir & '\devcon\i386\devcon.exe" hwids * >"' & @DesktopDir & '/DevconOutput.txt""', @SystemDir, @SW_HIDE)

Note that this is not part of a healthy balanced diet. Thank you M$ for including and allowing spaces in default system paths! :unsure:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0