Week 10 Tutorial
Week 10 Tutorial
Instruction:
Complete all questions in 1 hr.
Let’s get started with nice and easy examples of Batch script:
1. Open your favorite text editor. Save it as filename.bat (All files) right click on the file and
edit> type >
@echo off
echo Hello World!
pause
Run it. You have created your first batch file.
Ans. The @echo off command is used to prevent the command prompt from displaying
the commands before it after execution. Pause command is used to terminate program
and prevent from automatically closing the window.
2. Create a batch program which takes two numeric inputs from the user and checks
whether they are equal or not.
Fundamentals Of Computing Week 10 Tutorial
3. Create a batch program which takes a numeric input from the user and checks whether
the input is odd or even.
4. Create a batch program which prints natural numbers 1 to 10 using for loop.
Fundamentals Of Computing Week 10 Tutorial
5. Create a simple calculator using a batch script. Which takes two number and third inputs
can be “add” ,“sub”, “mul”, “div” and displays the result after calculation and displays
error message for any other input in the third. eg: if first input is 2 , second input is 3 and
third input is add then it displays the result 5. Note: use function
Fundamentals Of Computing Week 10 Tutorial
Fundamentals Of Computing Week 10 Tutorial
Fundamentals Of Computing Week 10 Tutorial
7. The following script is the malicious script responsible for system crash. Explain how it
works and explain how you can protect your pc from system crash in Windows OS and
Linux.
It is not permanently harmful for computers but annoying.
Warning: do not run this script.
:S
Start %0
Goto S
To protect your computer from system crash caused by malicious scripts like the one described,
it's important to be cautious when downloading and running scripts or files from untrusted
Fundamentals Of Computing Week 10 Tutorial
sources. You can avoid running the script by not executing it, or you can scan the file using a
reputable anti-virus program before running it to ensure its safe.
In case you accidentally run the script, you can use the Task Manager in Windows to end the
process of the script. Pressing "Ctrl + Alt + Del" will bring up the Task Manager, where you can
select the script from the list of running processes and click on "End Task" to stop it.
Another important step is to keep your computer updated with the latest security patches and
software updates. This will help ensure that any vulnerabilities in your computer's software are
fixed, making it less likely that a malicious script like this can cause a system crash.