How to Create a Text File
This is part of my series on How to Install Windows Applications Silently.
Often times their will be a need for you to create a ‘text’ file. This may be used to craft a ‘reg’ file, an ‘ini’ file, a ‘bat’ file, or just a simple ‘txt’ text file. This is very easy to do, and their are many ways to do it, but also a few methods to avoid. When considering which tool to use to create your text file, consider that many of the processes that may make use of that text file require that the file be ‘text only’, and won’t work properly if the file contains anything more. What this means is files created with programs capable of producing more than just ASCII characters may create a file that is not truly ‘text only’.
For example, if you use Microsoft Word, and simply type in plain text and save it, by default that file is not ‘text only’. You would need to do a ‘Save As…’ and choose ‘Plain Text (*.txt)’ as the file type for it to be text only. To avoid problems, I use the most simple program I can to create text files, one not capable of producing formatting and other content that text-only files cannot contain. My editor of choice is ‘Notepad’.
One way to create a new text file with Notepad is to go under the Start Menu to Programs and then Accessories and choose Notepad. This will start the program with a new text file window for you to type in. When you are ready to save the file, you should then type in the full name of the file you wish to create, which will add the proper extension (eg. text.bat). If you only type in the name, without an extension, the file will automatically have ‘.txt’ added to the name.
Another way to create a text file with Notepad is to right-click in the Explorer window where you want the file to exist, and choose New and then Text Document, which will create a file in that directory, and immediately prompt you to enter a name. Enter the full name of the file you wish to create, including the extension. If you enter an extension other than ‘.txt’ you will be prompted whether you want to change the extension of the file (since by default it would be .txt), go ahead and answer Yes. Once the blank file is created, you can then open it to add content.
Once you’ve created a file, using either one of these methods, or a number of other available options, you may not be able to double-click the file to edit it. For example, if the file ends with ‘.bat’ double clicking will try to execute the file, since .bat files are batch scripts. Double-clicking a .reg file will try to add it to the registry, since .reg is assigned to the Registry Editor program. To edit the file (ini, reg, bat, cmd, vbs, inf, and many other types) you can right click on the file and choose the Edit option from the menu. If this doesn’t open the file in Notepad, close whichever program opened, and instead you may be able to right-click on the file and choose Open With… which should allow you to choose Notepad from a list of programs. Finally, if neither of these methods work, open Notepad and use the Open command to go locate the file (you’ll need to change the Files of Type setting to All Files to see files that don’t end with .txt).
Another problem you can run into, even with Notepad, is that some programs will save a text-only file with ‘unicode’ characters, while other programs may not be able to understand unicode. To fix this, open the text file in Notepad, go to Save As… and change the Encoding setting at the bottom of the window to ANSI. Keep in mind that this could alter the file in a negative way (eg could strip out foreign language characters), but should allow any program to open it properly.
Following these steps should allow you to create any type of text-only file that you need in the process of creating your silent-installation packages.
Posted: 06 March 27
Under: Silent Installs
Viewed: 14,680 views
Getting all of a sudden in notepad when I try to save a file the following.. F:\is not accessible
the folder was moved or removed
When I click close it brings up my documents but it will not save the file.. can you help please
Does it allow you to change locations? F: sounds like a CD drive or something, maybe try your ‘My Documents’ folder to see if that works.
Notepad that’s a little plain isn’t it? Have you ever tried Notepad++? They just released the v3.40. Of course it’s going to be a little more resource heavy, but it’s a true friend of any programer.
I use Notepad++ for many things (it’s very nice, just wish it had a spell checker). For this writeup though, the simpler the better. Less to explain with Notepad, and fewer ways to screw up.
hi, i have a little problem with m ybatch file.
@echo
cls.
MD C:\NewFolder
UNRAR X MYFILE.rar C:\NewFolder
echo.
like you see i want to extract MYFILE.rar to the subfolder [NewFolder] of the Local Disk C:
ok, thats fine and it works.
but i want to extract MYFolder.rar exactly to the C: [my localdisk] and not to a subfolder of C: like NewFolder
so to batch that it should look like;
@echo
cls.
MD C:\
UNRAR X MYFILE.rar C:\
echo.
but it happens nothing, seemingly is this path write protected or is it NOT?
please reply how to get that work