Windows 7 creating blank txt file after running a batch script


  1. Posts : 1
    Windows 8.1 pro x64
       #1

    Windows 7 creating blank txt file after running a batch script


    I have the following batch script

    Code:
    @echo off
    
        setlocal enableextensions
    
        set "baseName=dnshistory"
    
        set "count=0"
        for /f "delims=%baseName%." %%a in (
            'dir /b /o-d "%baseName%*.txt" 2^>nul'
        ) do ( set /a "count=%%a+1" & goto saveData )
    
    :saveData
        ipconfig /displaydns | find "Record Name" > "%baseName%%count%.txt"
    The problem is that when i run it on my windows 7 desktop, it creates an empty txt file in comparison to my windows 8 laptop, where it creates the dns record that i need.

    Does anyone knows why this happens on windows 7 ?
      My Computer


  2. Posts : 5,092
    Windows 7 32 bit
       #2

    Usually inserting a bunch of "echo" statements will give a hint what's wrong. Just like using MsgBox in other programming languages.
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Are you running it from a Elevated Command Prompt? I think that's required.

    Run ipconfig /displaydns | find "Record Name" and see if it works. Then try it from a Elevated Command Prompt.
      My Computer


  4. Posts : 16,163
    7 X64
       #4

    It works on my win7.
      My Computers


 

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

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