Re: what kind of scripting is this ?
- From: David Brown <david.brown@xxxxxxxxx>
- Date: Thu, 20 Dec 2007 00:13:34 +0000 (UTC)
Hello Pegasus (MVP),
I agree - VBScript definitely wins for anything but the most simple tasks.
Batch does have the FOR command which allows looping, the CALL :LABEL that sort of gives you subroutines, and the SET command allows some rudimentary string parsing. It works OK if you need to talk to a command line utility like DSMOD or Robocopy. Batch becomes hard to deal with if your script has more than a couple dozen lines.
Batch files have no looping facilities other than a "goto" statement.
On the other hand they do have if/then/else constructs:
set name=%UserName%
if /i "%name%"=="Hassan" (
echo Good morning %name%
) else (
echo You're not %name%!
)
There are some string handling functions that are fully explained in
set /?. Here is an example:
set Name=Hassan the Programmer
echo Hassan is a %Name:~11%
Batch files have nothing in common with VB Scripting. VB Scripting
is far more powerful than batch file programming. It is also a lot
more verbose. Your initial request for archiving some files required
about four lines of batch file programming. In VB Scripting it would
require maybe 30 to 40 lines. Everyday file manipulation tasks can
often be performed with just a few lines of batch code. More
complex tasks are best performed with VB Scripts.
"Hassan" <hassan@xxxxxxxx> wrote in message
news:OlY1MpUQIHA.4752@xxxxxxxxxxxxxxxxxxxxxxx
Pegasus,
Im aware of finding how to use copy and robocopy, but what im not
aware of is assigning variables to them. Looks like you've given me a
clue with those echo and set.
So with that, are there any other commands from a logic perspective,
if then else, while ,etc.. what about string parsing ,etc. ?
Now does that get into vb scripting or can i still do it in a batch
file as such ?
Thanks
"Pegasus (MVP)" <I.can@xxxxxxx> wrote in message
news:eIUb1dUQIHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
"Hassan" <hassan@xxxxxxxx> wrote in message
news:esHKRLUQIHA.4136@xxxxxxxxxxxxxxxxxxxxxxx
Pegasus helped me in a previous message with a script as below:It is a batch file. A batch file consists of a collection of
@echo off
set Age=7
set Source=c:\Home\Hassan
set Target=c:\Home\Hassan\Archive
robocopy /mov /minage:%Age% "%Source%" "%Target%" *.txt
My question is , is the above kind of programming called vb
scripting or just windows scripting ?
Where can i learn more about it ? As Id like to learn the basics of
the above language that i can use to do some basic stuff on a day
to day basis on my windows machines
Thanks
commands
that you type at the Command Prompt. You can learn about the
commands by typing this at the Command Prompt:
echo /?
set /?
copy /?
robocopy /?
.
- Follow-Ups:
- Re: what kind of scripting is this ?
- From: Pegasus \(MVP\)
- Re: what kind of scripting is this ?
- References:
- Re: what kind of scripting is this ?
- From: Pegasus \(MVP\)
- Re: what kind of scripting is this ?
- Prev by Date: Re: ADO conditional insert, update, or delete
- Next by Date: Re: vbs to run thru list of files
- Previous by thread: Re: what kind of scripting is this ?
- Next by thread: Re: what kind of scripting is this ?
- Index(es):
Relevant Pages
|