Scripts Thread, What do you guys actually use batch files for? in Coding and Web Development; Okay, so long-story-short I've recently started an apprenticeship with a school as you might expect, that's involved delving into the ...
Okay, so long-story-short I've recently started an apprenticeship with a school as you might expect, that's involved delving into the Command Line more than I've previously done (the extent of my pre-apprenticeship CLI usage was mostly limited to ipconfig) - which has in turn gotten me somewhat inrigued into scripting.
I knew batch files existed but never really bothered with them until now, and using a few sites online that list commands, combined with a little intuition (and trial-and-error logic) I've so far coded two batch files..
One's a script that Y/N promps to back up E:\ drive (usb flash drive), if N is returned, it asks for a separate location to back up. It then creates date-named folders and xcopy's the files over.
The second's a (useless) script that asks for a number, starts at zero, and keeps adding 1 until it reaches that number. Admittedly I only wrote that one to discover if causing a coding loop was possible.
So I'm just wondering what more experienced techies might use batch files for, out of interest. I've seen most scripts here are what might as well be Klingon, since (as of yet) I know no programming languages (although I might just give a bash at learning one)
I have one batch file that runs all the install files for Reader, Flash etc. so if I'm "cleaning up" a system and it's easier than reaching for PDQ Deploy, I'll run that locally.
Also have one on login to add printers and shared drives, but I don't like doing that. It's something that was already here.
Also have our login/logoff logs as batch files. PM me if you'd like a copy of them.
As for learning a language - DO IT! It's extremely rewarding and useful. It's the equivalent of learning to grow and make your own food, not dependant on other people. Can't find an app to do something? Code it!
It depends what you want to do. For instance, if you need to create a lot of folders and assign specific security, it makes sense to use batch files as you're staying close to the native commands - e.g. md, icacls.
If you want to create AD users, you might use LDAP from VBS, or Powershell.
DOS/Windows batch files are really quite limited though, with flaky logic controls and hacks a plenty. Not so with Linux's Bash, however, you can actually write proper code in Bash.
I have various ones lying around but the majority of mine are VB scripts. However .bat files are a great way to ease yourself into scripting. The majority of my batch files tend to be for doing simple software installs based on certain criteria. For example:
if not exist path to reference file goto install
path to install / relevant switches for silent install
copy \\server\path\reference file to c:\path to reference file
Just simple stuff really. My more advance scripts - dealing with creating AD accounts and folders - tend to be in VB as I'm not fully confident on Powershell just yet
A lot of my scripts (mostly VBS) deal with automating repetitive SIMS tasks, e.g. converting my exported XML to Excel/Word, bulk setting of print options for exported marksheets, automated running of reports etc.
To the OP, have a real good nosy around in here, there are plenty of good examples you can hack apart and do 'stuff' with.
Really? I'm sure I posted it in Scripts.. That's what I get for having multiple tabs open >.> Whoopsie.
I'll make sure to have a good nosey around, but a lot of the stuff here confuses me as of current xD Possibly because I have no interaction with them before.. or any interaction with the software or setups they're written to work with..