CMD - get MAC address of iPhone - ios

Im trying to get the MAC address of my iPhone from my windows machine.
GETMAC /s 10.30.114.14
And it returns:
ERROR: The RPC server is unavailable
But if I try to get a MAC address of any other device (laptops and what not), I get a good address within milliseconds.
So Im asking: Is there a way to get a MAC address of an iDevice from CMD?
**I know I can look at the device settings, but that is realy not what I'm after.

ping it and then grab the MAC from the arp cache:
#echo off
set IP=10.30.114.14
ping -n 1 %IP% >nul
for /f "tokens=2" %%a in ('arp -a ^| find "%IP%"') do set MAC=%%a
echo MAC: %MAC%
pause

Suppose that you a have the inputfile with computers or ip address list, you can give a try with batch file :
#echo off
Title Get IP and MAC address for remote PCs over the network using batch
Set "Copyright=by Hackoo 2021"
Title %~nx0 %Copyright%
Mode con cols=90 lines=12
cls & color 0A & echo.
echo ********************************************************************************
echo Get IP and MAC address for remote PCs over the network by %Copyright%
echo ********************************************************************************
echo(
if _%1_==_Main_ goto :Main
:getadmin
echo %~nx0 : self elevating
set vbs=%temp%\getadmin.vbs
(
echo Set UAC = CreateObject^("Shell.Application"^)
echo UAC.ShellExecute "%~s0", "Main %~sdp0 %*", "", "runas", 1
)> "%vbs%"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
goto :eof
::-------------------------------------------------------------------------------------
:Main
set "InputFile=%~dp0Hosts.txt"
set "OutPutFile=%~dp0IP-MAC.txt"
If Exist "%OutPutFile%" Del "%OutPutFile%"
If Not Exist "%InputFile%" (
color 0C & echo "%InputFile%" does not exist. Please check it first !
Timeout /T 8 /NoBreak>nul & Exit
)
Netsh interface ip delete arpcache >nul 2>&1
#for /f "tokens=* delims=" %%H in ('Type "%InputFile%"') do (
Ping -n 1 %%H>nul
#for /f "tokens=2" %%M in ('arp -a %%H ^| find "%%H"') do (
echo %%H : %%M
echo %%H : %%M>>"%OutPutFile%"
)
)
If Exist "%OutPutFile%" Start "" "%OutPutFile%" & Timeout /T 1 /NoBreak>nul & Exit

Related

Pinging Hostnames from a Parsed File and Logging in Batch

I'm still pretty new to batch but I wanted to try out some different functionalities within the same batch program. Essentially, I am attempting to parse through a .txt file of hostnames and ping them 1 time each, and return a pass or fail by utilizing a find query for the specific ping result. The second find query is redundant but left in. A string of "timed out" indicates that the host is down. I have been able to achieve this with this bulky code, but my actual ping statistics are no longer being written to this log file.
I'm not too familiar with the command pipeline character but it may just be incompatible for this specific use case. If I remove the piped command for the find query, it is able to write the output of the ping command just fine, but then I lose the utility of a return pass or fail value. Is this just a simple syntax error? I've tried moving the location of the actual write to file argument on the line itself but it hasn't worked. Also, why are the errorlevel values inverted (line 21)? I can't seem to return what I'm looking for.
Is there anyway I can get all these parts to play nice together? I apologize if the answer is quite obvious...
#echo off
setlocal
set hosts=temp.txt
set count=0
echo.
echo Parsing File: %hosts%
echo.
echo Start > C:\Users\___\Downloads\pingLOG.txt
for /F "tokens=*" %%i in (%hosts%) do (
set /A count=count+1
echo+
echo.
echo [+] Pinging: %%i
echo [+] Pinging: %%i >> C:\Users\___\Downloads\pingLOG.txt
echo.
ping -n 1 "%%i" | find /I "timed out" >> C:\Users\___\Downloads\pingLOG.txt
if errorlevel == 1 (
echo Pass
) else (
echo Fail
)
echo.
echo %TIME% >> C:\Users\___\Downloads\pingLOG.txt
)
echo.
echo %count% Hosts Scanned
find /c "timed out" C:\Users\___\Downloads\pingLOG.txt
echo.
pause
You can't filter the output for a certain string and expect the complete output (eliminating unwanted parts is the very reason for filtering).
To accomplish your goal, you need a temporary file (the complete output) and filter that file, so you have both variants (filtered and unfiltered) (suboptimal, but well...):
ping -n 1 "%%i" >"%temp%\temp.tmp"
find /I "timed out" "%temp%\temp.tmp" >nul && set "status=Fail" || set "status=Pass"
type "%temp%\temp.tmp" >> "C:\Users\___\Downloads\pingLOG.txt"
echo %status% >> "C:\Users\___\Downloads\pingLOG.txt"

In Windows 7 identify ip of a mapped drive and reconnect it

I know that I can show mapped drives in windows 7 using
c:\>net use
and it shows
Status Local Remote Network
-------------------------------------------------------------------------------
OK X: \\192.168.168.100\c\Output
Microsoft Windows Network
OK Y: \\192.168.168.100\c\Input
Microsoft Windows Network
Is it possible to discover if X (or Y) are connected to ip 192.168.168.100 ?
And in this case disconnect them using
net use X: /delete
net use Y: /delete
and reconnect them to same path but different ip using (from 192.168.168.100 to 192.168.168.101)
net use X: \\192.168.168.101\c\Output /user:user01
net use Y: \\192.168.168.101\c\Input /user:user01
and viceversa, if they are connected to 192.168.168.101, disconnect and reconnect
to 192.168.168.100
Can someone help me to parse the net use output ?
Not pretty but it works in my limited testing:
#echo OFF
setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
goto start
:checkone
setlocal
echo INFO: %3 is mapped to drive %2
set "server="&set "new="
for /F "usebackq tokens=1,* delims=\" %%A in ('%3') do #set server=%%A&set share=%%B
if "%server%"=="192.168.168.100" set new=192.168.168.101
if "%server%"=="192.168.168.101" set new=192.168.168.100
if not ".%new%"=="." (
call net use %2 /delete
call net use %2 \\%new%\%share% /user:user01
)
endlocal
#goto :EOF
:start
for /F "tokens=*" %%A in ('net use^|find ":"^|find "\\"') do #for /F "usebackq tokens=1,* delims=:" %%B in ('.%%A') do call :checkone %%B: %%C
If the remote path has spaces there will probably be trouble...

Youtube-dl OUTPUT TEMPLATE %(title)s.%(ext)s is not working with set /p in windows

I used the batch file with commands :-
set /p ytlink="Enter the link of Youtube Video:- "
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" -o "D:\Videos\%(title)s.%(ext)s" %ytlink%
pause
but the output file name is (ext)s.webm ,it seems cmd is treating %(title)s.% in -o "D:\Videos\%(title)s.%(ext)s" as variable.So how to get video title?
OS=Windows 10 64bit 1909
youtube-dl=2020.01.24
You have to use double % in a batch file.
set /p ytlink="Enter the link of Youtube Video:- "
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" -o "D:\Videos\%%(title)s.%%(ext)s" %ytlink%
pause
Maybe someone will need it. Based on 1957classic answer. Download video and audio in the best quality to your desktop with the original name with the url taken from the clipboard.
setlocal enabledelayedexpansion
for %%I in (powershell.exe) do if "%%~$PATH:I" neq "" (
set getclip=powershell "Add-Type -AssemblyName System.Windows.Forms;$tb=New-Object System.Windows.Forms.TextBox;$tb.Multiline=$true;$tb.Paste();$tb.Text"
)
for /f "delims=" %%I in ('%getclip% ^| findstr /n "^"') do (
set "line=%%I" & set "line=!line:*:=!"
)
set "psCommand="[Environment]::GetFolderPath('DesktopDirectory')""
for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "Desktop=%%I"
%~d0"%~p0"youtube-dl.exe -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" -o "!Desktop!\%%(title)s.%%(ext)s" !line!

How to print multiple PDF files in different folders?

An example would be:
 Folder 1:
  a.pdf
  b.pdf
   Folder11
   c.pdf
  Folder 2:
  a.pdf
  b.pdf
   Folder21:
   c.pdf
printing all files between folders
And the cmd would have a way to find the file only putting part of the words?
Example
TEXT : ABC*.PDF
PRINT ABCDF.PDF
1. To loop over multiple files recursively:
FOR /f "tokens=*" %%F in ('dir /s /b *.pdf') DO echo "%%F"
dir /s /b *.pfd finds all pdfs (*.pdf), in all subdirectories (/s), in bare format - ie just the path name (/b)
DO echo "%%F" just echo's the result to the console.
"tokens=*" adds the whole line into %%F regardless of white spaces / other tokens
/F makes it run the ('dir ...') command
2. To print from command line use: From this question
AcroRd32.exe /t "C:\Folder\File.pdf" "Brother MFC-7820N USB Printer" "Brother MFC-7820N USB Printer" "IP_192.168.10.110"
Note: Path to AcroRd32.exe must be in your path environment variable
3. Putting it all together -- edit -- 'I've added taskkill to close acrord32 after printing
FOR /f "tokens=*" %%F in ('dir /s /b *.pdf') DO AcroRd32.exe /t "%%~F" "Brother MFC-7820N USB Printer" "Brother MFC-7820N USB Printer" "IP_192.168.10.110" & taskkill /IM AcroRd32.exe

How to check the existence of a Windows service in a batch file

How can I check the existence of a Windows service in a batch file?
The user is inputting a service name, and I want to check that the service does exist before continuing with my script.
Try this:
>NET START | FIND "Workstation"
where "Workstation" is the name of the service
#echo off
color 1F
SET KEYS=HKLM\SYSTEM\CurrentControlSet\services\ACPI
for /f "tokens=3" %%i in ('REG QUERY "%KEYS%" ^| find "Start"') do set START=%%i
IF "%START%" == "%START%" ECHO %START% | find /I "%START%" && IF "%START%" NEQ "0x3" REG ADD %KEYS% /v "Start" /t REG_DWORD /d 3 /f >> %COMPUTERNAME%_MODIFIER.TXT
IF ERRORLEVEL 1 ECHO %KEYS% >> %COMPUTERNAME%_SERVICE_MISSING.TXT
OR
#echo off
color 1F
#sc query >%COMPUTERNAME%_START.TXT
ECHO REPORT MISSING INSTALL SERVICES >%COMPUTERNAME%.TXT
find /I "AcPrfMgrSvc" %COMPUTERNAME%_START.TXT >nul
IF ERRORLEVEL 1 NET START "AcPrfMgrSvc"
IF ERRORLEVEL 1 ECHO AcPrfMgrSvc >>%COMPUTERNAME%.TXT

Resources