Question

In: Computer Science

Create a batch file that gathers network information from a remote host. Use your VMs for...

Create a batch file that gathers network information from a remote host. Use your VMs for this

Solutions

Expert Solution

@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

REM set variables
set system=
set manufacturer=
set model=
set serialnumber=
set osname=
set sp=
set cstring=
set ustring=
set pstring=

REM Get Computer Name / IP Address
echo ----------------
echo Type in a Computer Name or IP Address and press Enter
set computer=%computername%
set /p computer=[Press Enter For %computername%] 
echo ----------------

REM Check If Remote Machine
IF NOT %computer% == %computername% goto remote
goto start

:REMOTE
REM It's A Remote Machine
set cstring=/node:"%computer%"

:USERNAME
REM Get Username
echo ----------------
echo Type in a Username and press Enter (with or without DOMAIN)
set user=%username%
set /p user=[Press Enter For %username%] 
echo ----------------

REM Check If Other Username
IF NOT %user% == %username% goto newuser
goto start

:NEWUSER
REM It's A Different User
set ustring=/user:"%user%"

:PASSWORD
REM Get Password
echo ----------------
echo Type in a Password and press Enter (with or without DOMAIN)
set pass=
set /p pass= 
echo ----------------

REM Check if password was entered
IF [%pass%] == [] goto nopass
set pstring=/password:"%pass%"
goto start

:NOPASS
REM No password entered
set pstring=

:START
cls
echo Checking connection [Computer: %computer%]...
echo Please Wait....

REM Check connection
wmic %cstring% %ustring% %pstring% OS Get csname

IF %errorlevel% == -2147023174 goto norpc
IF %errorlevel% == -2147024891 goto baduser

echo Getting data [Computer: %computer%]...
echo Please Wait....

REM Get Computer Name
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% OS Get csname /value') do SET system=%%A

REM Get Computer Manufacturer
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% ComputerSystem Get Manufacturer /value') do SET manufacturer=%%A

REM Get Computer Model
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% ComputerSystem Get Model /value') do SET model=%%A

REM Get Computer Serial Number
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% Bios Get SerialNumber /value') do SET serialnumber=%%A

REM Get Computer OS
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% os get Name /value') do SET osname=%%A
FOR /F "tokens=1 delims='|'" %%A in ("%osname%") do SET osname=%%A

REM Get Computer OS SP
FOR /F "tokens=2 delims='='" %%A in ('wmic %cstring% %ustring% %pstring% os get ServicePackMajorVersion /value') do SET sp=%%A

echo done!

echo ----------------
echo System Name: %system%
echo Manufacturer: %manufacturer%
echo Model: %model%
echo Serial Number: %serialnumber%
echo Operating System: %osname%
echo Service Pack: %sp%
echo ----------------

REM Generate file
SET file="%~dp0%computer%.txt"
echo ---------------- > %file%
echo Details For %computer%: >> %file%
echo System Name: %system% >> %file%
echo Manufacturer: %manufacturer% >> %file%
echo Model: %model% >> %file%
echo Serial Number: %serialnumber% >> %file%
echo Operating System: %osname% >> %file%
echo Service Pack: %sp% >> %file%
echo ---------------- >> %file%

echo File created at %file%

REM request user to push any key to continue
pause

goto END

:NORPC
echo ----------------
echo Error...No connection could be made to [%computer%]...
echo Error...Please try again...
echo ----------------
pause
cls
goto winnt

:BADUSER
echo ----------------
echo Error...Access Denied using [%user%]...
echo Error...Please try again...
echo ----------------
pause
cls
goto username

:NOCON
echo ----------------
echo Error...Invalid Operating System...
echo Error...No actions were made...
echo ----------------
pause
goto END

:END

Related Solutions

Suppose Host A wants to send a large file to Host B. The path from Host...
Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1 = 200 kbps, R2 = 2 Mbps, and R3 = 1 Mbps. Assuming no other traffic in the network, what is the average throughput for the file transfer? Suppose the file is 4 million bytes, on average, how long will it take to transfer the file to Host B? Repeat (a) and (b), but...
We are sending a MP3 file of 300,000 bits from Host A to Host B. Host...
We are sending a MP3 file of 300,000 bits from Host A to Host B. Host A and B are each connected to a switch S via 100 Mbps links. Assume that each link introduces a propagation delay of 10 µs (microsecond). Calculate the total transfer time of the entire file (from first bit sent to last bit received) for the following: Suppose the MP3 file is sent as one message. S is a store-and-forward device; it begins retransmitting immediately...
Consider sending a large file of F bits from Host A to Host B. There are...
Consider sending a large file of F bits from Host A to Host B. There are three links (and two switches) between A and B, and the links are uncongested (that is, no queuing delays). Host A segments the file into segments of S bits each and adds 80 bits of header to each segment, forming packets of L=80+ S bits. Each link has a transmission rate of R bps. Find the value of S that minimizes the delay of...
Consider sending a large file of F bits from Host A to Host B. There are...
Consider sending a large file of F bits from Host A to Host B. There are three links (and two switches) between A and B, and the links are uncongested (that is, no queuing delays). Host A segments the file into segments of S bits each and adds 80 bits of header to each segment, forming packets of L=80+ S bits. Each link has a transmission rate of R bps. The link propagation delay, let's call it d, was not...
How long does it take to send a 15 MiB file from Host A to Host...
How long does it take to send a 15 MiB file from Host A to Host B over a circuit-switched network, assuming: - Total link transmission rate = 49.7 Gbps. - Network is FDM, with 7 permitted users, each with an equal bandwidth share. - A link connection requires a setup time of 84.5 ms. Your answer should be in miliseconds (ms) with one decimal place, and without the unit (e.g. "140.6" without the quotes)
Create a geoprocessing tool from the .py file included (script from this file included below). Use...
Create a geoprocessing tool from the .py file included (script from this file included below). Use any csv file you would like. I will work around that. This is for a programming for GIS class. We work with jupyter, idle, arcgis pro import os import arcpy from arcpy import env input_table = r"C:\Answers\January2018.CSV" output_fc = r"C:\Answers\crime.gdb\January2018_Crime" spRef = arcpy.SpatialReference("NAD 1983 StatePlane Missouri East FIPS 2401 (US Feet)") gdb_name = os.path.dirname(output_fc) fc_name = os.path.basename(output_fc) env.overwriteOutput = True print("Creating File GDB") arcpy.CreateFileGDB_management(os.path.dirname(gdb_name),...
The internet is host to a wealth of information and much of that information comes from...
The internet is host to a wealth of information and much of that information comes from raw data that have been collected or observed. Many websites summarize such data using graphical methods discussed in this chapter. Find a website related to your major that summarizes data and uses graphs, and share it with the class. Let us know how it relates to your major and why it is of interest to you. My major is Accounting
A store gathers some demographic information from their customers. The following chart summarizes the age-related information...
A store gathers some demographic information from their customers. The following chart summarizes the age-related information they collected: Age Number of Customers <20<20 67 [20-29) 68 [30-39) 87 [40-49) 57 [50-59) 62 ≥60≥60 58 One customer is chosen at random for a prize giveaway. Enter your answers as either decimals or fractions, not as percents. What is the probability that the customer is at least 20 but less than 60?     (Round to 4 places) What is the probability that the...
We are sending a MP3 file of 1,000,000 bits from a source host to a destination...
We are sending a MP3 file of 1,000,000 bits from a source host to a destination host. All links in the path between source and destination have a bandwidth of 10 Mbps. Assume that the propagation speed is 2.5 * 10 8 meters/sec, and the distance between source and destination is 10,000 km. 1. Now suppose there are two links between source and destination, with one switch connecting the two links. Each link is 5,000 km long. Again suppose the...
Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT