Save to file from command line operation and named it as [hostname].txt

7,988

You want the %computername% environment variable.

So, the command you need is ipconfig /displaydns >%computername%.txt You can find a more complete list of environmental variables in Daniel Beck's answer

Share:
7,988

Related videos on Youtube

ehh
Author by

ehh

Updated on September 18, 2022

Comments

  • ehh
    ehh over 1 year

    I am wondering if it is possible to save the following operation to a file while the name of the file is the host name:

    I mean something like:

    ipconfig /displaydns >hostname.txt
    

    For example, in case my PC name is ehh then it will save to ehh.txt file

  • ehh
    ehh about 7 years
    Great, works perfectly!!!