I need to display connected Ethernet name.
I used the following command to get WLAN connected network (Wi-Fi).
C:\Users\User>netsh wlan show interface | findstr /i "SSID" name
SSID : HOME
BSSID : bc:62:d2:4a:a1:48
An error message is output if I run the following command next:
C:\Users\User>netsh lan show interface command
The Wired AutoConfig Service (dot3svc) is not running.
But after I started the service, I still do not get the active connected Ethernet name.
C:\Users\User>netsh lan show interface command
There is 1 interface on the system:
Name : Ethernet
Description : Realtek PCIe GbE Family Controller
GUID : e901d916-86f4-4070-9941-47a9a325537a
Physical Address : 98-E7-43-0F-8F-84
State : Connected. Network does not support authentication.
Can anyone help me to get the Ethernet name Home on wired LAN connection?
The following command, entered directly in cmd, should display the name of the connected network profile(s), regardless of whether they are wired or wireless, on a Windows 8 / Server 2012 Operating System or newer.
For /F Tokens^=6^ Delims^=^" %G In ('%SystemRoot%\System32\wbem\WMIC.exe /NameSpace:\\Root\StandardCimv2 Path MSFT_NetConnectionProfile Where "IPv4Connectivity='4'" Get Name /Format:MOF 2^>NUL') Do #Echo %G
From a batch-file, for GUI double-click, it would look a little more like this:
#(For /F Tokens^=6^ Delims^=^" %%G In ('%SystemRoot%\System32\wbem\WMIC.exe
/NameSpace:\\Root\StandardCimv2 Path MSFT_NetConnectionProfile Where
"IPv4Connectivity='4'" Get Name /Format:MOF 2^>NUL') Do #Echo %%G) & Pause
I am trying to add a line to my start up scrip which would automatically start the VPN if I am connected to WiFi networks outside of my work.
I can get the names from netsh wlan commands, but I am not able to just "pick" the SSID/network name from that.
Is there a way to extract particular information from the netsh output or is there a way to output just the wifi name?
Thanks in advance.
You can use the findstr command to find a string in a commands, specifically the SSID.
Script:
#echo off
set "wifiNetwork=example network"
(netsh wlan show networks | findstr /C:": %wifiNetwork%" >nul 2>&1)&&goto :found
echo Wi-Fi network "%wifiNetwork%" not found
goto :end
:found
echo Wi-Fi network "%wifiNetwork%" found!
:end
pause
NOTE: The findstr command is case-sensitive unless you add the /I option
I was trying to get the below information related to the drivers.
Name, INFFile, Vendor, Version, Description, and Date.
All the information i could find it using the below command.
"devcon drivernodes"
But this is only working in local machine. (Checked with MSDN and came to know that we cannot get the remote machine details with this command.
Do we have any other utility / way to get the mentioned details from a remote computer?
I am capturing all the details using VBScript (using .exec method and stdout.readline method)
Thanks in Advance
Does
wmic /node:computerlist.txt sysdriver get /format:list
Computerlist.txt is a list of IP addresses or computernames.
For local computer
wmic sysdriver get /format:list
See wmic /? (for a partial list of what's available), wmic sysdriver get /?, and wmic /format /?.
EDIT
To get file versions, if a file has one. Note backslashes have to be doubled.
Filever.bat filename
set filepath=%~f1
set file=%filepath:\=\\%
wmic datafile where name^="%file%" get version|findstr /i /v /c:"version"
To start a program (it will be invisible on remote computers)
wmic process call create c:\\windows\\notepad.exe
I am writing a shell script which runs on cygwin console for windows, my scritp looks like this
#!/usr/bin/bash
cmd /c start /d "C:\cygwin\bin" ipconfig | findstr /R /C:"IPv4 Address"
ipconfig #to print
route add 10.2.139.1 192.168.104.1
But when i execute this script on cygwin console it shows below error and even i changed to ipconfig \all it doesn't work
Error: unrecognized or incomplete command line.
USAGE:
ipconfig [/allcompartments] [/? | /all |
i am trying to get ip address dynamically by executing the script and adding to the route table
Thanks,
Rohith
I don't know why you did this with cygwin instead of cmd.exe, what you use it for and why use start, but, all you missing is one option /b:
cmd /c start /d "C:\cygwin\bin" /b ipconfig | findstr /R /C:"IPv4 Address"
And start is redudant as follows:
cmd /c ipconfig | findstr /R /C:"IPv4 Address"
/b just suppresses the newly created cmd.exe background window.
Quite simply, how does one determine whether or not Tomcat is running in Windows, using the command prompt?
I am writing a batch script that must do this. This is the Bash version:
RESULT=`netstat -na | grep $2 | awk '{print $7}' | wc -l`
Where $2 is the port.
I am looking for something similar to that. Using Cygwin is out of the question, of necessity this script must be able to run on machines that only have Tomcat.
Test the status of the Tomcat Service with the SC command. MJB already suggested to test the service status with SC, yet another batch script (without FOR loop) for testing the status:
#ECHO OFF
SC query tomcat5 | FIND "STATE" | FIND "RUNNING" > NUL
IF ERRORLEVEL 1 (
ECHO Stopped
) ELSE (
ECHO Running
)
If you are not sure if the service name is tomcat5 you can list all service names with
SC query state= all | FIND "SERVICE_NAME"
You could use tasklist to check if the tomcat executable is running. For example:
#echo off
tasklist /FI "IMAGENAME eq tomcat.exe" | find /C /I ".exe" > NUL
if %errorlevel%==0 goto :running
echo tomcat is not running
goto :eof
:running
echo tomcat is running
:eof
It is also possible to check a remove server using the options /S, /U and /P. See tasklist /? for details.
Using WMIC
#echo off
wmic process list brief | find /i "tomcat.exe"
set result=%ERRORLEVEL%
if "%result%"=="1" echo "not running"
if "%result%"=="0" echo "running"
note : /i is to make the find operation case-insensitive.
This is the Windows version of the netstat based UNIX/LINUX solution asked in the question:
#echo off
netstat -na | find "LISTENING" | find /C /I ":8080" > NUL
if %errorlevel%==0 goto :running
echo tomcat is not running
goto :eof
:running
echo tomcat is running
:eof
Well, I am not very good with scripts but perhaps you could use this as a starting point:
netstat -a -n | findstr :8005
To get if someone is listening in port 8005. That is Tomcat's default port for remote administration, i.e. startup or shutdown.
Alternatively you could use the port that the http server listens to.
Hope this helps
use netstat -a in command prompt.
You'll find 8080 port listed there.
If you run Tomcat for Windows not like a service and don't want to exploit JMX the best way is
for /F %%I in ('tasklist /FI "WINDOWTITLE eq Tomcat" /NH') do if %%I==java.exe goto alreadyRun
where:
Tomcat - the window title of the Tomcat's terminal window by default
java.exe - the name of the Tomcat's processe. NOT tomcat.exe.
Yet another option, since this is probably running as a service
FOR /F "tokens=4 delims= " %%A IN ('SC QUERY tomcat5 ^| FIND "STATE"') DO SET status=%%A
echo "%status%"
status can be things like STOPPED, RUNNING ...
I check it by calling a vb script from command line
cscript //nologo checkurl.vbs | findstr "200"
IF errorlevel 1 GOTO :not_running
Save the below script as checkurl.vbs and replace the ip with machines ip
' Create an HTTP object
myURL = "http://10.1.1.1:8080/"
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
' Download the specified URL
objHTTP.Open "GET", myURL, False
On Error Resume Next
objHTTP.Send
intStatus = objHTTP.Status
If intStatus = 200 Then
WScript.Echo intStatus
Else
WScript.Echo "Error Connecting"
End If
I had problems with using sc query command, because even if tomcat crashed, the service would still be shown as running where in actual the port was not accessible
You can try searching for the process and extracting the line
For example:
ps|grep tomcat