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...
1. A file of size 500 MB is to be transferred from host H1 to host...
1. A file of size 500 MB is to be transferred from host H1 to host H2 through routers R1, R2 and R3. See Figure 1 below. h1=2mbs=>R1==8mbs=>R2==10mbs==>R3=1mbs==>h2 (a) If the file is transmitted is one entity, without dividing it into smaller chunks, estimate how long it would take for the file to arrive at the receiver. [4 marks] (b) If the file is first divided into smaller chunks, and each chunk is transmitted and then combined, estimate how long...
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),...
Write a program that gathers input from the user and writes the information out to a...
Write a program that gathers input from the user and writes the information out to a file (output.txt).   Your main method should gather the input, calculate the average, and write the output. You should have a separate method that writes the output to a file. You can have other methods as well if you choose. However, you MUST have at least one other method in addition to the main method. Inputs: Student Number Name Class name Grades 1-5 (5 individual...
Linux Use touch to create a file in your working directory called PutFileHere this is a...
Linux Use touch to create a file in your working directory called PutFileHere this is a linux question i acidentally put javascript when i first submitted it
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT