0

I am making a script that will get the IP address when ran on a computer.

Currently I have this code:

FOR /F "tokens=4 delims= " %%i in ('route print ^| find " 0.0.0.0"') do set localIp=%%i
>%~dp0%localIP%.txt echo %localIp%
attrib +h opened /s /d
del /f  %~dp0%localIP%.log
SET LOGFILE=D:\%localIP%.log
call :Logit >> %D:\%localIP%.log% 
exit /b 0
:Logit

ipconfig

echo MSGBOX "IP adress gotten" > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs /f /q

I am looking for a way to take localIp as well as the generated localIp.log file that gets generated from the script, and email them both to myself automatically in the script. Is there a way to do this in a batch file?

mason
  • 31,774
  • 10
  • 77
  • 121
Skeledog
  • 21
  • 5
  • 1
    That would be easier with PowerShell. Are you open to using that? There's a [Send-MailMessage](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7.1) commandlet that makes it very easy to send email from script on stock Windows. – mason Mar 03 '21 at 21:50
  • I would be open, as long as powershell could be opened with the same ease as double clicking a batch file – Skeledog Mar 03 '21 at 21:51
  • I am very new to any form of programming like this so I will probabaly need a lot of help to get anything in powershell to work lol – Skeledog Mar 03 '21 at 21:53
  • 1
    Well the best way to get started is reading the documentation. If you get stuck, provide a [mcve] and clearly explain what's not working. – mason Mar 03 '21 at 21:53
  • You can also do the email with Vbscript as well. Which is what it looks like you are attempting to do. Should be a really easy search to find the Vbscript or Powershell email solution by searching StackOverFlow with the appropriate tags or just using Google. – Squashman Mar 04 '21 at 00:57

0 Answers0