WEBVTT

00:00.720 --> 00:02.189
Hello and welcome to the mainland.

00:02.760 --> 00:03.689
This video we're going to learn

00:03.690 --> 00:05.009
about Windows bad scripting.

00:05.220 --> 00:06.220
I'm Christopher Heller.

00:06.230 --> 00:07.230
And let's begin.

00:08.130 --> 00:09.329
So we're learning objects for this

00:09.330 --> 00:10.679
video. We're going to understand the

00:10.680 --> 00:12.720
purpose of a bad script for Windows.

00:12.990 --> 00:14.189
We're going to learn how to write a

00:14.190 --> 00:15.709
bad script, and we are going to

00:15.960 --> 00:17.649
execute a bad script as well.

00:19.410 --> 00:20.410
Now, pretty assessment.

00:20.520 --> 00:21.839
What is the well known file

00:21.840 --> 00:23.309
extension for when there's bad

00:23.310 --> 00:25.320
scripts? Is it A bad

00:25.920 --> 00:27.149
B batch?

00:27.510 --> 00:28.510
C, the VBS or

00:29.460 --> 00:30.760
D Makram?

00:32.299 --> 00:33.818
The answer is a dump, that this

00:34.340 --> 00:36.270
is the Windows File extension for

00:36.320 --> 00:38.035
batch scripts, and it helps Windows

00:38.180 --> 00:40.009
file system identify which

00:40.010 --> 00:41.299
program it should use to

00:41.300 --> 00:43.460
automatically open and execute

00:43.490 --> 00:44.490
this file.

00:44.610 --> 00:46.009
But that batch is not a valid

00:46.010 --> 00:47.010
extension.

00:47.330 --> 00:49.189
The feebs macro

00:49.400 --> 00:50.809
are different types of scripting

00:50.810 --> 00:51.810
files for windows

00:52.820 --> 00:54.200
and not for batch scripts.

00:56.130 --> 00:57.899
So the purpose of Bache groups is

00:57.900 --> 00:59.400
very similar to

00:59.970 --> 01:01.850
the Linux Shell

01:01.890 --> 01:03.262
scripts, where if we write a

01:03.720 --> 01:05.189
whole bunch of commands that we

01:05.400 --> 01:06.809
don't want to have to keep writing

01:06.810 --> 01:08.329
out over and over again, we can

01:08.730 --> 01:10.494
type them into a bad script and then

01:10.560 --> 01:11.939
we can either double click the file

01:11.940 --> 01:13.655
to have an execute force or execute

01:13.950 --> 01:15.239
it directly in the terminal.

01:16.050 --> 01:17.639
And we can have other processes

01:17.640 --> 01:18.680
executed as well.

01:19.080 --> 01:21.209
So say with the service control,

01:21.210 --> 01:23.189
if we have a specific service

01:23.190 --> 01:25.589
where we want it to execute

01:25.590 --> 01:27.510
a specific command, if it fails,

01:28.080 --> 01:29.969
we can use the best script that

01:29.970 --> 01:31.830
we wrote, giving it specific

01:32.160 --> 01:33.959
directions and commands to execute

01:34.230 --> 01:35.798
and say, hey, if you fail, we're

01:36.060 --> 01:38.099
in this bad script so

01:38.280 --> 01:39.449
it can be executed by other

01:39.450 --> 01:41.400
terminals or other processes.

01:41.670 --> 01:43.409
And like we have the

01:43.680 --> 01:44.680
bad extension.

01:46.830 --> 01:48.409
So we write a bad script,

01:48.780 --> 01:49.907
we have a few different

01:50.700 --> 01:52.560
uses we can have,

01:52.860 --> 01:54.526
we can have these labels which are

01:54.660 --> 01:56.569
very useful in order to help

01:56.580 --> 01:58.499
loop in a different way than the

01:58.860 --> 02:00.400
other Windows loops that we learned.

02:00.960 --> 02:02.909
So if we have these colan

02:02.910 --> 02:05.249
for a label, it creates a specific

02:05.250 --> 02:06.920
section in the script for us.

02:07.440 --> 02:09.149
And then later on in the script, if

02:09.150 --> 02:11.159
we say, hey, I want you to go to

02:11.160 --> 02:12.875
this label, it will go back to that

02:12.990 --> 02:13.990
specific spot.

02:14.430 --> 02:15.780
So as we see

02:16.290 --> 02:17.290
excuse me, let

02:18.150 --> 02:19.150
me get my pen.

02:19.770 --> 02:21.689
So as we see, we put the colon

02:21.690 --> 02:22.860
and start here.

02:22.980 --> 02:24.909
So this created the label for start.

02:25.500 --> 02:26.939
Now it'll echo.

02:27.490 --> 02:28.490
Hello.

02:28.500 --> 02:30.068
That is the next command and the

02:30.150 --> 02:31.759
command. After that, it says, hey,

02:31.780 --> 02:33.479
you need to go to start.

02:33.990 --> 02:35.759
And that will send it right back up

02:36.180 --> 02:37.180
to the start.

02:37.410 --> 02:39.210
And then we'll keep executing down

02:40.140 --> 02:41.319
and we'll say, All right, I need to

02:41.340 --> 02:43.289
echo hello and says, all right,

02:43.290 --> 02:45.054
I need to go to start and we'll just

02:45.090 --> 02:46.315
keep looping in this way.

02:46.560 --> 02:47.879
So it's a very useful way to be able

02:47.880 --> 02:49.105
to loop inside of a batch

02:49.800 --> 02:50.639
file.

02:50.640 --> 02:51.419
So I'll give you a quick

02:51.420 --> 02:52.890
demonstration of that, my text

02:53.400 --> 02:55.229
file folder to see

02:55.230 --> 02:56.230
what is inside.

02:56.610 --> 02:58.169
And let's say I have the loop.

02:58.170 --> 03:00.419
Not that now I'm going to

03:00.870 --> 03:02.242
type them, looped up that to

03:02.730 --> 03:03.659
see what's inside.

03:03.660 --> 03:05.129
And this is the same file we were

03:05.130 --> 03:06.779
looking at in the PowerPoint

03:06.780 --> 03:07.780
presentation.

03:07.870 --> 03:09.291
It's going to start akolo and

03:09.780 --> 03:10.780
then go back to start.

03:11.370 --> 03:12.959
Now, what's a little different in

03:12.960 --> 03:14.528
Windows is that we don't need to

03:15.120 --> 03:17.279
do the dot forward slash.

03:17.520 --> 03:18.629
We can just type the name of the

03:18.630 --> 03:20.300
batch file enter

03:20.700 --> 03:21.960
and it is going nuts.

03:22.110 --> 03:23.849
So I'm going to do control see

03:24.030 --> 03:25.469
and say, yes, I want to terminate

03:25.470 --> 03:27.209
this bad job because I don't want to

03:27.210 --> 03:28.580
keep looping forever and ever.

03:30.150 --> 03:31.739
So we can also get very creative

03:31.740 --> 03:33.406
with the batch files and the Linux

03:33.720 --> 03:34.720
Shell files.

03:34.890 --> 03:36.449
And if you haven't learned already

03:36.450 --> 03:38.430
the color command it'll use,

03:38.910 --> 03:40.527
it will change the foreground and

03:40.530 --> 03:41.951
the text color of the command

03:42.240 --> 03:44.339
window. So if we say,

03:44.370 --> 03:46.499
hey, I want you to keep changing

03:46.500 --> 03:48.019
the color of the background and

03:48.330 --> 03:49.830
keep changing the color of the text

03:50.160 --> 03:51.238
and then go back up to

03:51.990 --> 03:52.829
the start.

03:52.830 --> 03:54.389
So this is very similar to our last

03:54.390 --> 03:55.979
one. Keep changing the colors.

03:56.460 --> 03:58.175
Now, I'm going to run this command.

03:58.770 --> 04:00.093
And if you don't like a lot

04:00.600 --> 04:01.874
of bright flashing colors,

04:02.610 --> 04:04.129
then I suggest you go ahead and

04:04.620 --> 04:06.300
skip forward about 30 seconds.

04:07.020 --> 04:08.430
So let's see. I have the colors

04:08.880 --> 04:10.595
that that I'm going to execute this

04:10.830 --> 04:12.339
and it is going absolutely nuts.

04:12.340 --> 04:14.099
So I'm going to terminate that and

04:14.100 --> 04:15.100
say we're done.

04:15.360 --> 04:17.039
But that's a very useful way to kind

04:17.040 --> 04:18.809
of loop through and get creative

04:18.810 --> 04:19.979
with what we're doing with the batch

04:19.980 --> 04:20.980
files.

04:21.779 --> 04:23.519
So Mexican bad scripts, as we've

04:23.520 --> 04:25.019
already learned, we can type the

04:25.020 --> 04:26.549
file names directly into the command

04:26.550 --> 04:28.709
prompt so we can do just colors,

04:28.710 --> 04:29.949
not that like we just did.

04:30.550 --> 04:32.020
Now you need to be in the same

04:32.550 --> 04:34.619
directory as the file you're going

04:34.620 --> 04:35.620
to execute.

04:35.730 --> 04:36.869
If you are not in the same

04:36.870 --> 04:38.634
directory, then you will either need

04:38.790 --> 04:40.829
to type the full folder structure,

04:40.830 --> 04:42.949
the absolute path for that file.

04:43.200 --> 04:45.149
So that is a another way

04:45.150 --> 04:46.829
to stay inside the same working

04:46.830 --> 04:48.779
directory you're in, but also access

04:48.780 --> 04:49.956
that file in a different

04:50.730 --> 04:51.730
directory.

04:52.890 --> 04:53.890
It's a post assessment.

04:53.970 --> 04:55.410
How do you create labels in the

04:55.660 --> 04:57.690
script? Is it a semicolon,

04:58.050 --> 04:59.879
B colon, C

05:00.000 --> 05:01.829
parentheses or D

05:01.860 --> 05:02.860
forward slash?

05:04.420 --> 05:06.190
The answer is B a coin.

05:06.400 --> 05:08.079
This creates the label that we can

05:08.350 --> 05:09.918
use to go to command in order to

05:10.210 --> 05:11.778
keep looping or create different

05:11.920 --> 05:13.759
functionality inside of that script.

05:14.140 --> 05:15.849
So it's very useful to keep this in

05:15.850 --> 05:17.049
mind while you're writing these vast

05:17.050 --> 05:18.609
groups in order to be able to become

05:18.610 --> 05:19.720
effective at what you're doing.

05:21.430 --> 05:22.949
So in this video, we learned we

05:23.380 --> 05:25.139
understood the purpose of a bad

05:25.180 --> 05:26.797
script. We learned how to write a

05:26.890 --> 05:28.213
bad script, and we executed

05:28.930 --> 05:30.489
a script from the command line.

05:30.670 --> 05:32.139
And I hope to see you in the next

05:32.140 --> 05:32.410
50.

