Phil Factor's Phrenetic Phoughts

Simple-Talk columnist
The wilder shores of Transact SQL    Phil on Twitter   Phil on SQL Server Central  Phil on BOS

The DOS Batch File from Hell: a confession.

Published Monday, September 22, 2008 12:02 PM

A while back, I was chatting to an IT Support person we’d recently taken on. I discovered that he’d come from a large multinational company that I’d also once worked for.

“It was interesting work.” He said, “There was one curiosity about it, though; The PCs all ran a huge, complex, system for keeping the installations up-to-date. It was based on DOS batch files, for heavens’ sake. When the PCs were switched on, they ran a complex set of batch processes that could run installs, upgrades, or whatever was needed. It all worked fine but it was quite mad. It was very difficult to understand. I’d love to speak to the crazy guy who wrote it and ask him what possessed him to do so.”

“You’re speaking to him. Ask away, matey”.

He was struck dumb with embarrassment. He needn’t have worried; I take the word ‘mad’ as a compliment; in fact, I’m content with almost any human interaction nowadays..

“It was nearly twenty years ago I wrote that. I should explain why."

(cue 'sincerity' music)

"I was charged with coming up with a rational plan for maintaining a network of around a thousand PCs, doubling in size every year. At the time, they had MSDOS, and not much else. How could one check the configurations of the PCs, install software when required, do backups, and maintain a list of who had what software? There were far too many to do by hand, and my budget was vanishingly small.

At that time, there was nothing on the market to do the job. SMS, later called System Centre Configuration Manager, was a long way in the future.

Just to make matters difficult, the IT director had twitched himself awake at some point and decided that nobody in the IT should be allowed to do any programming. Henceforward, all programs would be written by outside companies, and we would merely ‘facilitate’ and manage the projects, write specifications, and supervise acceptance-tests: you know, that sort of thing.

Fine, but these guys from outside companies like to be paid, and I hadn’t the budget.

In your working life, you will often be asked to do impossible things. This is normal, and reflects the fact that life itself is a juggling act that we all eventually fail at.

You may, when you reach the point of being asked for the impossible, become despondent. Not I, for this is a game better than chess, it is referred to colloquially in Britain as the Game of Silly Buggers. (GSB). This is much enjoyed by managers in large companies as it keeps boredom at bay, and defeating this type of management torpidity is the source of great pleasure to those who like to get things done. It is, essentially, the intellectual game of getting around the arcane rules and regulations of large companies, the creeping sclerosis in corporate systems. At work, you generally have to do urgent and important things without being given the time, permission, or resources to do so. The best tactic when trapped in this particular Game of Silly Buggers is to first study the rule-book and exploit the loopholes in the ‘GSB’.

After having read the corporate computer manual cover-to-cover, I began to suspect a flaw in their definition of what comprised an ‘application’, and what therefore constituted ‘programming’.

I phoned the Manager in charge of ensuring compliance.

“Ah, Phil!” (Thinks: what is that fox up to now?)

“Ron, please excuse me, but I’m having some difficulty understanding paragraph 345 sub-paragraph 4: Definition of a computer application. I was hoping for your able assistance”

“I’m only too pleased to assist!” (Thinks: He’s on to some loophole, damn him) “What was the nature of your difficulty?”

“I can understand that an application consists of code, which is subject to all the normal corporate constraints. If I were to write a DOS batch file, would that be deemed to be an application?

“Yes” (Thinks: go away Phil! Hang on a mo. We’ll be swamped with applications!)”No. No, no.”(Thinks: Phew, narrow escape there).

“Excellent. As I tend to get confused, can you just write me an email to that effect?”

“Yes. Was that all?” (Thinks: Go away, Go! Go!)

“It was most satisfactory, Thanks for all your kind help.”

There is little more I need to say. If a DOS batch file was not an application than I would construct a system out of DOS batch files, and escape the ban on developing code, and the almost impossible barriers put in place by the corporate test team. The production managers cursed impotently. They couldn’t prevent it. . The whole IT management structure of the company seemed to focus on stopping the initiative, and the moment it looked like succeeding, announced that it was their doing or idea in the first place.

I discovered amazing things you can do with batch files. Even now I tremble at the potential power offered by SQL Server’s xp_cmdShell As so often in the GSB, the attempt to maintain the day to day equilibrium by preventing any initiatives, actually can lead to a paradoxical breakthrough in the ways of making things happen. I’ll admit, however, that the code looked strange to anyone brought up on Pascal or C++. Although I was proud of the system, and it stood the test of time, I shall take to my grave the memory of that awful look of reproach given me by the unfortunate programmer tasked with maintaining the code after I’d left the department. He had just experienced the start of his own battle with the fates, the Game of Silly Buggers."

Comments

 

bradmcgehee said:

The last company I worked for ($8 Billion in sales) also used batch files just like you described. They were written by a "server guy" who had long ago left the company, but in spite of this, were still working just like they day he left.
September 23, 2008 7:01 AM
 

willcas said:

So very true, as a quite green behind the ears junior programme I joined my first investment bank from a software house in the pursuit of more cash and promises of leading edge technologies.
I was stunned to find 80% of the key nightly processes running in batchfiles and started trying to evangelise even a move to vbscript until an old dog gave me the low down with the phrase. "The entire city is held together with batchfiles and bluetack"
So very true
October 6, 2008 8:55 AM
 

Alexander Karmanov said:

Yep, batch flies of mine have killed a few full-blown projects having them replaced with a couple of one-to-dozen-line scripts :). More to come... well, if only replacing those scripts with 'normal' app could bring me anything tangible but headache...
October 18, 2008 8:55 PM
You need to sign in to comment on this blog


















<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
Finding Stuff in SQL Server Database DDL
 You'd have thought that nothing would be easier than using SQL Server Management Studio (SSMS) for... Read more...

Mission Critical: SQL Server 2008 Performance Tuning Task List
 In which Buck Woody imagines how the US military would have tackled DBA checklists for... Read more...

Simple Query tuning with STATISTICS IO and Execution plans
 A great deal can be gleaned from the use of the STATISTICS IO and the execution plan, when you are... Read more...

Switching rows and columns in SQL
 When they use SQL Server, one the commoner questions that Ms Access programmers ask is 'Where's the... Read more...

Writing Efficient SQL: Set-Based Speed Phreakery
 Phil Factor's SQL Speed Phreak challenge is an event where coders battle to produce the fastest code to... Read more...