Desktop shortcut with output redirection


  1. Posts : 261
    Windows 10 Pro x64 Version 1903
       #1

    Desktop shortcut with output redirection


    I have a shortcut on my desktop for a GUI appliction that had a Target like:

    C:\somepath\myprog.exe

    that works fine!

    I then changed it to read:

    C:\somepath\myprog.exe >C:\temp\myprog.log 2>&1

    but that didn't create the log file at all

    What have I got wrong?

    Thanks
    David
      My Computer


  2. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    David,

    What was wrong with
    Code:
    C:\somepath\myprog.exe >C:\temp\myprog.log
    ?

    Denis
      My Computer


  3. Posts : 261
    Windows 10 Pro x64 Version 1903
    Thread Starter
       #3

    Because that only captures stdout. I want both stdout and stderr captured to the same file.

    David
      My Computer


  4. Posts : 261
    Windows 10 Pro x64 Version 1903
    Thread Starter
       #4

    ????
      My Computer


  5. Posts : 261
    Windows 10 Pro x64 Version 1903
    Thread Starter
       #5

    The following (copied into notepad) worked!

    Desktop shortcut with output redirection-image.png

    but why?

    PS I tried to enter that into my post as text and was summarily blocked!??
      My Computer


  6. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    I'm sorry that I originally failed to spot that we were discussing a shortcut rather than a straightforward command.
    By adding anything to a shortcut [other than a simple argument to pass to the executable] you risk having to make a compound cmd command. For example, this is my [elevated] SFC shortcut
    Code:
    FFFF /k "C:\Windows\System32\sfc.exe /ScanNow & Title SFC complete"
    {It was my desire to have a window title that forced me into compund commands on this occasion}

    I don't understand why you used Start /B, by the way.

    PS I have also had some weird blocked messages when posting here over the last week or so. And I was just blocked when I posted this with my example included [so I've just blocked out cmd to see if it will now work].

    Denis
      My Computer


  7. Posts : 261
    Windows 10 Pro x64 Version 1903
    Thread Starter
       #7

    I just copied the incantation from another forum ...

    D,
      My Computer


  8. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #8

    I also tried to post this afterwards
    Desktop shortcut with output redirection-text-too-short-not-posted.png

    Denis
      My Computer


  9. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #9

    This was the example I tried to post earlier on

    Code:
    %windir%\system32\cmd.exe /k "C:\Windows\System32\sfc.exe /ScanNow & Title SFC complete"
    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:03.
Find Us




Windows 10 Forums