Batch Wake-On-Lan
Posted: 24 Dec 2013 04:59
Is there any way to implement WOL functionality in batch without the need of third-party software?
thephantomblu wrote:Is there any way to implement WOL functionality in batch without the need of third-party software?
Code: Select all
c:\> cscript //nologo something.vbs
thephantomblu wrote:No, you misunderstood me.
Is there any way you can send WOL packets through batch without third-party software?
ghostmachine4 wrote:To send WOL packets programmatically you need the UDP protocol and for that you need to program using a language that support the UDP packet programming. If you really cannot use any other third party software (note, vbscript is installed by default and to me not considered third party), vbscript (or powershell) is your best bet. vbscript doesn't support sockets natively but you can call activex/com control ( Mswinsck.ocx etc ? Please research google for more) . if you have powershell on newer systems, you can make use of .Net libraries System.Net.Sockets API.
penpen wrote:Maybe this is what you are searching for:
http://analects.jeffharbert.com/a-vbscript-wake-on-lan-project/.
(Especially the last script at the bottom of this page.)
penpen
Code: Select all
Set objShell=CreateObject(“wscript.shell”)
strCommand=”C:\scripts\wol.exe” & strMAC
Set objExec=objShell.Exec(strCommand)
Code: Select all
:main
@echo off
setlocal
cls
set "vbc="
pushd "%SystemRoot%\Microsoft.NET\Framework"
for /f "tokens=* delims=" %%i in ('dir /b /o:n "v*"') do (
dir /a-d /b "%%~fi\vbc.exe" >nul 2>&1 && set "vbc="%%~fi\vbc.exe""
)
popd
if defined vbc (
echo most recent VB.NET compiler located in:
echo %vbc%.
) else (
echo VB.NET compiler not found.
goto :eof
)
%vbc% /nologo /target:exe /out:"%~f1.exe" "%~f1.vb"
goto :eof
thephantomblu wrote:Is there any way to implement WOL functionality in batch without the need of third-party software?
penpen wrote:To avoid compiling an executable file, a powershell 2.0 version can be found here:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/51ef86e5-f3d4-459c-a08a-615c669aff2e/script-to-turn-on-wake-on-magic-packet-from-off-state?forum=ITCG
penpen
foxidrive wrote:Here's a powershell solution that may work:
http://gallery.technet.microsoft.com/sc ... n-815424c4
thephantomblu wrote:can we call Powershell scripts in a batch file?
thephantomblu wrote:
penpen, can we call Powershell scripts in a batch file?