Skip to content

maha712/Windows-basic-commands-batchscript

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Windows-basic-commands-batchscript

NAME:Mahalakshmi K

REG NO:212222240057

AIM:

To execute Windows basic commands and batch scripting

DESIGN STEPS:

Step 1:

Navigate to any Windows environment installed on the system or installed inside a virtual environment like virtual box/vmware

Step 2:

Write the Windows commands / batch file . Save each script in a file with a .bat extension. Ensure you have the necessary permissions to perform the operations. Adapt paths as needed based on your system configuration.

Step 3:

Execute the necessary commands/batch file for the desired output.

WINDOWS COMMANDS:

Exercise 1: Basic Directory and File Operations

Create a directory named "my-folder"

500439613-6e31e28a-06ba-462e-82e2-f142db81dca2

COMMAND AND OUTPUT

Remove the directory "my-folder"

500439789-8d0ab4fa-cc28-4953-bb2d-b9082b984e93

COMMAND AND OUTPUT

Create the file Rose.txt

500439948-73dd0bb2-7930-4f20-a2ae-e0ed3d0003e8

COMMAND AND OUTPUT

Create the file hello.txt using echo and redirection

500440343-ae2bce38-39e8-4b0e-bdc0-6fd525825ea6

COMMAND AND OUTPUT

Copy the file hello.txt into the file hello1.txt

500440478-ad794fea-a16b-4fbe-aa61-a0deb25df2d6

COMMAND AND OUTPUT

Remove the file hello1.txt

500440830-4213e6cb-6277-44a5-83b4-9c72a82087a9

COMMAND AND OUTPUT

List out the file hello1.txt in the current directory

500440951-76661426-93dc-4fb3-88b5-58ea094b0d7a

COMMAND AND OUTPUT

List out all the associated file extensions

500441034-1af2cf24-0996-4254-8229-ee06e35dfab4 500441161-633cdca9-3d65-4545-bb5a-ff650394637b

COMMAND AND OUTPUT

Compare the file hello.txt and rose.txt

500443265-f78dc30e-5fc5-4716-982e-edb8a6d8de6d

Exercise 2: Advanced Batch Scripting

Create a batch file named on the desktop. The batch file need to have a variable assigned with a desired name for ex. name="John" and display as "Hello, John".

Modify the script to delete files with the ".docx" extension from the "Documents" folder after creating the backup.

@echo off
mkdir %userprofile%\Desktop\DocBackup
copy %userprofile%\Documents\*.docx %userprofile%\Desktop\DocBackup
del %userprofile%\Documents\*.docx
echo Backup and deletion completed successfully!

OUTPUT

376104140-ddf657d3-b54a-44c7-8393-615d081e9043

Create a batch file on the desktop that checks whether a user-input number is odd or not. The script should: Prompt the user to enter a number. Calculate the remainder when the number is divided by 2. Display whether the number is odd or not. Ask the user if they want to check another number. Repeat the process if the user enters Y, and exit with a thank-you message if the user enters N. Handle invalid inputs for the continuation prompt (Y/N) gracefully.

OUTPUT

500443587-a187e800-8d6e-4fd8-8caf-1a2ef69892c9

Write a batch file that uses a FOR loop to iterate over a sequence of numbers (1 to 5) and displays each number with the label Number:. The output should pause at the end.

OUTPUT

500443672-272d0b8f-ee8e-4f89-9e2f-57cabd58aa20

Write a batch script to check whether a file named sample.txt exists in the current directory. If the file exists, display the message sample.txt exists. Otherwise, display sample.txt does not exist. Pause the script at the end to view the result.

Instructions: Use the IF EXIST conditional statement. Make sure the script works for files located in the same directory as the batch file. Use pause to keep the command window open after displaying the message. Expected Output (if the file exists):

OUTPUT

500444002-45c154db-9bc2-465b-8be1-66bd61409460

Write a batch script that displays a simple menu with three options: Say Hello – Displays the message Hello, World! Create a File – Creates a file named newfile.txt with the content This is a new file Exit – Exits the script with a goodbye message The script should repeatedly display the menu until the user chooses to exit. Use goto statements to handle menu navigation.

OUTPUT

500444182-f729795b-814f-472d-a218-8a51a19cc70f 500444246-f97dd16e-931d-4300-be6b-4e1e88dec21e 500444685-c1b7b68d-afca-479c-92f8-eabf4c042104

RESULT:

The commands/batch files are executed successfully.

About

Ex08-Windows-basic-commands-batchscript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published