How to Make Batch Files Install Any File!

116,842

12

26

Posted

Introduction: How to Make Batch Files Install Any File!

Ever want to give a download on an instructable, but it has to be in the correct folder? Here's how you can make a simple installer that can create multiple files, given you created it correctly. You will need

-a Windows NT (or higher) computer
-patience
-a file you want to install
-a place to put the file

Step 1: The Most Basic of Text Editing

Before we start programming we are going to have to open notepad.

Windows 95-2000
Start>Programs>Acessories>Notepad

Windows XP-7

Start>All Programs>Acessories>Notepad

Then proceed to the next step.

Step 2: The Code

This time you have to create the code. But I will show you how. Make sure you write down the code in notepad.

Say you file has two lines that are

This is the best instructable ever!
Thanks to Super_Nerd

And you want to put it in the filepath

C:\Users\ Users name goes here\Desktop

You start the code with

@echo off

Otherwise every command would have a C:\Windows\System 32 in front of it.

Then for every line in the file put

echo data in the line>>filepath

For the filepath involving the username where the username has to be, put

%USERNAME%

So in our case the code would be

@echo off

echo This is the best instructable ever!>>C:\Users\%Username%\Desktop\file.txt
echo Thanks to Super_Nerd>>C:\Users\%Username%\Desktop\file.txt

exit

Say you want to overwrite a file. To do so just make the >> to an >

> = Overwrite
>> = Add to file

Therefore to overwrite, make the first line have a > and the rest have >>.

See where the code says file.txt? That is the filename. Feel free to change it to whatever you want. If you don't add an extention it turns into a file. Confusing right? A file is a file with no extention, hence you have to choose what to open it with every time.

Step 3: Adding the 1s and 0s to the Drive

AKA saving the file

Save it as something like installer.bat

It can be whatever you want as long as it ends in .bat or .cmd

Step 4: Fire It Up!

Now test your new creation by double clicking on the icon with the gears. As always comment any problems or ideas you had.

See Ya!

Share

Recommendations

  • Space Challenge

    Space Challenge
  • Microcontroller Contest

    Microcontroller Contest
  • Spotless Contest

    Spotless Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

25 Comments

So as to be able to self teach some more, is there anyway to open or view the coding behind any program to start understanding what code ill need to add for specific functions? Say i want to make my own installer for a file of my own, and i would like to learn how C-Net makes their installers so i could replicate it for my own file, would i be able to tap into their code files? Is this illegal?

The legality of such actions is entirely based on the license the software is under. If it's free, most likely it's open sourced and it's totally fine. If you bought the software, probably not. As for installing executables in such a way, good luck, but most likely it probably won't work. This method really only works with text characters just based off of the fact it's comprised of DOS commands. Binary executables aren't limited to text characters so you might find difficulty copying everything into a batch file.

Ah, well thanks for that.

Though, I'm not sure if it installs stuff.

I used batch files for Quite a long time. I look forward into Programming.

I'm fairly new to batch files, so I'm hoping you can help me. I am running updates and a few installs on roughly 450 computers. Because our network is older, we have to do most of the installs and updates ourselves. Is it possible, and would it save time, to create a batch file that copies half a dozen files from the server to the desktop and installs them automatically, even if the installs have multiple 'clicks?' I have to log into our districts' filter first. I also run Windows Updates, clean out old system files, run ScanDisk and Disk Defrag, and create a restore point.

Any ides?

Thanks!

Most of that would be possible as it's copying and running files, however, I'm not to sure how well networked storage works with batch files. It's certainly worth a try though. Difficulty may arise in file paths if the files to be copied have different names/paths every update, but other than that, I'd imagine such a file could be created.

I had some success copying the folder from the network drive to my desktop, although it made it a folder within a folder on my desktop...

How would you go about writing instructions to install a program where you have to "opt out" of add-ons like toolbars, etc.? For example, when installing Java, you have to run the .exe, Tell UAC to allow the install, then click "Install" within in installation program. After a couple of minutes, an option to set everything to Yahoo comes up. After declining that, it will install Java. There are usually three more "Nexts" to click before the install is complete and all old versions are removed.

Most of what you're asking isn't possible through ordinary batch files. As they can only run DOS commands, they can't do everything. You would probably want to make a VBS script to go though the installation (although I have pretty much no experience with using VBS with other programs, I do believe there are some interaction features.) As for UAC, there isn't a non-manual way around it as it's designed to not be automated to help protect your system from viruses and other malware. The only way to not have to deal with it is to disable it, which can be done through the control panel. Phew, hope that helps.

Thanks. I kind of figured there wasn't going to be an easy way out of doing all those computers manually. I appreciate the advice though!