Re: scripting vs. batch files?
- From: Corné Bogaarts <does.not.exist@xxxxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 22:49:54 +0200
On Mon, 22 Aug 2005 12:53:16 -0400, "David H. Lipman"
<DLipman~nospam~@Verizon.Net> wrote:
>From: "Linn Kubler" <lkubler@xxxxxxxxxxxxxxxxxx>
>
>| Hi,
>|
>| I've been using batch files for ages, nothing too complex but useful. I was
>| just trying to figure out how, in my logon batch file, I could detect if a
>| client was Windows 2000 or Windows XP. One of the solutions suggested is in
>| the form of a VB script. So that made me wonder...
Using reg.exe from the resource kit (and commands like 'find' and 'if exist'
you can do a similar thing in a batch-file.
By using the propper commandline tools you can do an awfull lot with
relatively simple bat/cmd files. Especially in WinXP and Win2003 since they
contain ever more command line tools of their own.
>|
>| Can you incorporate scripting syntax in a batch file or should I stop using
>| batch files for logon scripts or what?
You can start a script from a batchfile with a command like 'cscript
<scriptfilename>'. Although that doesn't look like the best way to go.
>Just how do you decide when to use
>| scripting and when to use batch files?
It all depends on what you want to do and what's most easy for a particular
task.
>|
>| I'm browsing through the scripting center right now and am also wondering
>| the best way to learn scripting... are there any good books on the subject,
>| or which are the best books? Or, is it just as easy to work through the
>| examples in the scripting center?
I don't know about 'the best', I only have my own experience. I found the
'Windows 2000 Scripting Guide'
http://www.microsoft.com/technet/scriptcenter/guide/default.mspx
extremely instructive and a good place to start. If you really wanna study the
text, you might wanna buy it though, as the website doesn't quite read as easy
as a real book.
Another one is the 'MS Windows Scripting Self-paced learning guide' from MS
Press.
The way I started learning it, is by starting with simple scripts (usually
copy/paste from the Scripting Center website or one of the scriptomatics) and
just modifying things. Gradually I started adding various example-scripts
together to make them do what I want, for instance reading a list of
computernames from a file and then performing a particular command on each
computer.
Some time ago I found myself 'writing' a script that contained some 15 or 20
pieces from various sample-scripts: reading from a textfile, database-like
searching in the file, finding data on users and their manager in AD, writing
it to an Excel-file. Things I hadn't imagined myself doing just half a year
before.
>|
>| Any thoughts?
>|
>| Thanks in advance,
>| Linn
>|
>| P.S. Remove the "2" from my domain name for email responses.
>|
>
>The following Kixtart { http://kixtart.org Kixtart is CareWare } script snippet can
>determine the OS by querying the Registry...
>
>if (readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion","CurrentVersion")="4.0")=1
> $OS="WINNT4"
>endif
>if (readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion","CurrentVersion")="5.0")=1
> $OS="Windows 2000"
>endif
>if (readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion","CurrentVersion")="5.1")=1
> $OS="Windows XP"
>endif
>if (readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion","CurrentVersion")="5.2")=1
> $OS="Windows 2003 Server"
>endif
>
>Using a scripting language far ouweighs BAT and CMD scripts as you can do much more. There
>are even macros in Kixtart to directly determine the OS without querying the Registry. For
>one you can peek and poke the Registry. Another is you can use Windows Management
>Instrumentation constructs.
.
- References:
- scripting vs. batch files?
- From: Linn Kubler
- Re: scripting vs. batch files?
- From: David H. Lipman
- scripting vs. batch files?
- Prev by Date: RE: Simple AD shell script - discover usernames
- Next by Date: Remove multiple SID's?
- Previous by thread: Re: scripting vs. batch files?
- Next by thread: Re: scripting vs. batch files?
- Index(es):
Relevant Pages
|