Batch Wake-On-Lan
Moderator: DosItHelp
-
- Posts: 5
- Joined: 24 Dec 2013 04:53
Batch Wake-On-Lan
Is there any way to implement WOL functionality in batch without the need of third-party software?
-
- Posts: 319
- Joined: 12 May 2006 01:13
Re: Batch Wake-On-Lan
thephantomblu wrote:Is there any way to implement WOL functionality in batch without the need of third-party software?
you can do that with a vb script. I personally have not tried it but you can download the code here.
save it as something.vbs , edit the settings to your liking and execute
Code: Select all
c:\> cscript //nologo something.vbs
-
- Posts: 5
- Joined: 24 Dec 2013 04:53
Re: Batch Wake-On-Lan
No, you misunderstood me.
Is there any way you can send WOL packets through batch without third-party software?
Is there any way you can send WOL packets through batch without third-party software?
-
- Posts: 319
- Joined: 12 May 2006 01:13
Re: Batch Wake-On-Lan
thephantomblu wrote:No, you misunderstood me.
Is there any way you can send WOL packets through batch without third-party software?
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.
-
- Posts: 5
- Joined: 24 Dec 2013 04:53
Re: Batch Wake-On-Lan
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.
Oh, okay. I will see if I can get anything about vbscript on Google. Thanks for the reply!
Re: Batch Wake-On-Lan
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
http://analects.jeffharbert.com/a-vbscript-wake-on-lan-project/.
(Especially the last script at the bottom of this page.)
penpen
-
- Posts: 5
- Joined: 24 Dec 2013 04:53
Re: Batch Wake-On-Lan
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)
It uses an external application wol.exe. Any other ideas?
Re: Batch Wake-On-Lan
Sry, haven't inspected the source above fully (beside wol can be downloaded from http://www.gammadyne.com/cmdline.htm).
But maybe this may help you:
http://stackoverflow.com/questions/19508431/sending-magic-packet-with-vbs
(This should be a VB.NET source file, if i see it right.)
Additionally you may save this batch file as vbc.bat:
and compile the linked script using vbc.bat.
penpen
Edit: The .net framework has to be installed.
But maybe this may help you:
http://stackoverflow.com/questions/19508431/sending-magic-packet-with-vbs
(This should be a VB.NET source file, if i see it right.)
Additionally you may save this batch file as vbc.bat:
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
penpen
Edit: The .net framework has to be installed.
Re: Batch Wake-On-Lan
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
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
Re: Batch Wake-On-Lan
good to see there is a way to do it with Powershell.
-
- Posts: 1
- Joined: 24 Dec 2013 22:39
Re: Batch Wake-On-Lan
thephantomblu wrote:Is there any way to implement WOL functionality in batch without the need of third-party software?
what system are you running on? If its newer version, check if you have powershell installed.
-
- Posts: 5
- Joined: 24 Dec 2013 04:53
Re: Batch Wake-On-Lan
So I think there is absolutely NO way to do this in native batch.
penpen, can we call Powershell scripts in a batch file?
Thanks. This code looks cleaner!
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
penpen, can we call Powershell scripts in a batch file?
foxidrive wrote:Here's a powershell solution that may work:
http://gallery.technet.microsoft.com/sc ... n-815424c4
Thanks. This code looks cleaner!
Re: Batch Wake-On-Lan
thephantomblu wrote:can we call Powershell scripts in a batch file?
You can, though there can be issues with permissions and the default restrictions in Powershell.
Re: Batch Wake-On-Lan
thephantomblu wrote:
penpen, can we call Powershell scripts in a batch file?
you can run powershell from batch. See here