Question

Create a Windows batch script that: Execute the correct commands redirecting output to command-name.txt in BootDrive\newfolder2...

Create a Windows batch script that:

  1. Execute the correct commands redirecting output to command-name.txt in BootDrive\newfolder2 in order to get the output below:
    1. Environment variable
    2. System information
    3. Mac address (You cannot use the ipconfig command)
    4. DNS table
    5. Export the system.evtx file to BootDrive\newfolder2\sys.evtx
  2. Use a FOR loop to:
    1. Execute hostname and send the output to a variable host
    2. Output the variable host to BootDrive\newfolder2\casefile\host.txt
  3. Use an if statement to determine if sys.evtx exists (from #4)
    1. If sys.evtx exists echo sys.evtx successfully created
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey, it's a very interesting exercise in batch programming. For simplicity purposes, I had divided the solution into parts:

So, let's start:

PART ONE: REQUIREMENTS:

!. Create a batch script that does the following operations

2. Execute the commands for the above-mentioned requirements and store their output in a file in BootDrive\newfolder2

3. Store the hostname of the computer in a variable and then export it into a file BootDrive\newfolder2\casefile\hosts.txt

PART TWO: WRITING OUR BATCH SCRIPT:

Created a folder structure like this:

In this case, I am considering my E drive as a boot drive.

For environment variables:

For system information:

For MAC Address:

For DNS Table:

Copying System.evtx file:

Checking the sys.evtx file created or not:

Storing hostname in a variable and then exporting into a file:

PART THREE: COMPLETE SCRIPT:

================SCRIPT IN TEXT FORMAT=================

@echo off
REM START OF SCRIPT
cd /d E:\newfolder2


REM ENVIRONMENT VARIABLES
set > "set.txt"


REM SYSTEM INFORMATION
systeminfo > "systeminfo.txt"


REM MAC ADDRESS
getmac > "getmac.txt"


REM DNS TABLE
ipconfig /displaydns > "ipconfig_displaydns.txt"


REM COPYING SYSTEM.EVTX File
copy "C:\Windows\System32\winevt\Logs\System.evtx" "E:\newfolder2\sys.evtx" > "Copy_System_evtx.txt"

REM CHECKING THE FILE
if exist sys.evtx echo "sys.evtx successfully created"


REM STORING HOSTNAME IN A VARIABLE
FOR /F "tokens=*" %%a in ('hostname') do SET host=%%a
REM Creating CaseFile directory if ooesn't exist
if not exist casefile mkdir casefile
echo %host% > casefile\hosts.txt

================SCRIPT IN TEXT FORMAT=================

PART FOUR: GENRATED FILES:

Genrated File Contents:

For privacy purposes, private details are hidden :p

I hope it helped you in achieving your objective.

Please don't forget to thumbs up if it really helped you.

Keep learning and keep HomeworkLibing :)

Happy Coding

**********************************COMPLETE*****************************

Add a comment
Know the answer?
Add Answer to:
Create a Windows batch script that: Execute the correct commands redirecting output to command-name.txt in BootDrive\newfolder2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a Windows batch script. The batch script will contain the following: Ask the user interactively:...

    Create a Windows batch script. The batch script will contain the following: Ask the user interactively: Boot drive letter of the computer Computer name Computer Model Check to see if the boot drive in #1 exists with the folder newfolder (#1 above) If yes cd BootDrive\newfolder If no, make the directory BootDrive\newfolder Check to see if casefile.txt exists: If yes goto the label DONE Tell the user that data already exists in the newfolder folder and exit the program Output...

  • You will create a shell script that prints out the following information about the system it is run on: • The system’s n...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

  • 18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one...

    18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT