Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows 7 creating blank txt file after running a batch script

12 Jul 2014   #1
kikirikoukiko

Windows 8.1 pro x64
 
 
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 System SpecsSystem Spec
.
12 Jul 2014   #2
MilesAhead

Windows 7 32 bit
 
 

Usually inserting a bunch of "echo" statements will give a hint what's wrong. Just like using MsgBox in other programming languages.
My System SpecsSystem Spec
12 Jul 2014   #3
Ztruker

Windows 10 Pro X64
 
 

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 System SpecsSystem Spec
.

12 Jul 2014   #4
SIW2

Microsoft Community Contributor Award Recipient

Vista x64 / 7 X64
 
 

It works on my win7.
My System SpecsSystem Spec
Reply

 Windows 7 creating blank txt file after running a batch script




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Creating a batch script or use a 3rdpartyprogram to create shortcuts
Hello! I'm having trouble creating a batch script to simply copy a shortcut to the desktop from a program installation, then carry out some tasks. Overall my goals are: Burn a CD that includes a autorun.inf that will load a batch script In the script I want it to activate two self...
General Discussion
Is there a Script or batch file that can create folders by date range
I was wondering if there was a way to create a set of folders in a specific directory according to a date range that i input. ie. Select start date 2011 10 01 select end date 2012 10 01 Select Output path of c:\users\XXXX\desktop\export data
General Discussion
PDF file association REG or Batch Script
At work i use 2 different PDF viewing software. One is Adobe for editing and the other is Foxit for quick viewing. They have their pros and cons and so I use them interchangeably. For some work I will use Foxit for several hours at a time and only open something in Adobe on an as needed basis...
Software
Creating a welcoming batch file...
I need help creating batch file that will do the following... I want it to echo "Welcome (insert name here)." I want it to say "How are you today, good or bad?" If G, I want it to display, "That's great to know, sir! Would you like me to open your homepage? If Y, I want it to execute cd...
Software
Creating a WinPE Script File
Hello All, I'm using the WIAK CD to create a winpe boot media and it works fine, there are a few commands that you have to remember so I created a winpe.cmd file to make life easier. Here is the content of my winpe.cmd file: copype x86 c:\winpe copy c:\winpe\winpe.wim...
Installation & Setup


Our Sites

Site Links

About Us

Find 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 21:39.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App