none
How can I hide/suppress the output of a Diskpart script in a batch file? RRS feed

  • Question

  • Hi everyone,

    I have a deployment batch file that I use for running diskpart on a system and then deploying an image through either ImageX or DISM. 

    The script is fairly straight forward and first runs diskpart using a script, like this:

    > diskpart /s MyDiskpartCommands.txt

    Then, it executes the dism apply image command.

    What I'd love to do, since I have everything else in the batch file set to @ECHO off, is the equivalent of that for the diskpart commands which all show up as they're being ran (the commands themselves don't, but the output does).  Does anyone know a way to do this to make the script run clean, except for the echoes I'm explicitly sending to the user?

    Thanks!

    Friday, March 16, 2018 12:17 AM

Answers

All replies

  • This is not a diskpart or system utilities forum.  Post in the Windows General forum for your OS.

    You can also look up how to redirect output for batch commands. Here is an example of how to use a search engine for these kinds of questions:

    https://www.google.com/search?newwindow=1&source=hp&ei=PBOrWszdGqHn_QbR1aeQAw&q=redirect+diskpart+output&oq=redirect+diskpart+output&gs_l=psy-ab.3..0i22i30k1.942.6767.0.7001.25.24.0.0.0.0.147.2458.10j14.24.0....0...1.1.64.psy-ab..1.24.2455.0..0j46j0i131k1j0i46k1j0i10k1j0i22i10i30k1.0.nRpRCo9WqFQ


    \_(ツ)_/

    Friday, March 16, 2018 12:46 AM
  • This is not a diskpart or system utilities forum.

    No, but it is a scripting forum and I mistakenly thought my scripting question would most be suited for a scripting forum.  I searched the forum topics originally for something along the lines of "Windows Deployment", but didn't see anything in the rather large array of forum options, so I figured if anyone knew scripting it would be someone in the scripting forum.

    Post in the Windows General forum for your OS.

    I'll try that then, thanks!

    You can also look up how to redirect output for batch commands.

    Hm, I tried that but it didn't seem to work for lines containing a diskpart script, but this may be the direction I need to look further down.  I'll see what I can find.

    Here is an example of how to use a search engine for these kinds of questions

    -_-

    Thanks, I'll pass that sick tip on to my grandparents.

    Friday, March 16, 2018 1:48 AM
  • DISKPART is not a script or a scripting command.  It is an external utility.  The way external programs function is specific to each program.  You will always need to learn how your external program works in order to use it in any scripting language.

    Research each external program using whatever help is provided by the utility vendor and use you search engine to find answers to any questions you have.

    The output of some utilities and external programs cannot be suppressed by any normal means because the vendor or author has done non-Windows compatible things to force output.  We cannot advise you of that in a scripting forum.  There may be a simple answer but it is not a scripting issue to discover how your external program works.


    \_(ツ)_/

    • Marked as answer by link470 Friday, March 16, 2018 4:51 AM
    • Unmarked as answer by link470 Friday, March 16, 2018 5:39 PM
    Friday, March 16, 2018 1:54 AM
  • diskpart /s MyDiskpartCommands.txt > nul

    • Marked as answer by link470 Friday, March 16, 2018 5:44 PM
    Friday, March 16, 2018 5:38 PM
  • diskpart /s MyDiskpartCommands.txt > nul

    Thank you!  This is exactly what I was hoping would work.  Just tried it and it worked as expected.  Marking as correct answer.

    Appreciate your time!

    Friday, March 16, 2018 5:45 PM