batch not running correctly

November 15, 2010 at 07:09:03
Specs: Windows Server 2008
I'm writing a simple batch script to automate Wake-On-LAN for computers on my LAN. Script is below:

[CODE]@echo off
set GLOWS1=20cf30a799b2
set GLOWS1IP=
set GLOWS2=20cf30a798fd
set GLOWS2IP=
set GLOWS3=20cf30a7996b
set GLOWS3IP=
set GLOWS4=20cf30a79321
set GLOWS4IP=*.103
set GLOWS5=20cf30a7cd35
set GLOWS5IP=*.100
set GLOWS6=20cf30a8ebcd
set GLOWS6IP=
set GLOWS7=
set GLOWS7IP=
set SERVER=6cf049dfab46
set SERVERIP=*.120

:WOLmenu
echo ---GLOWS WOL Tool---
echo Please enter the PC you wish to wake via LAN
echo.
echo 1. GLOWS1
echo 2. GLOWS2
echo 3. GLOWS3
echo 4. GLOWS4
echo 5. GLOWS5
echo 6. GLOWS6
echo 7. GLOWS7
echo 8. SERVER

set /P wolchoice=Please enter your choice
if "%wolchoice%"==1 goto :GLOWS1
if "%wolchoice%"==2 goto :GLOWS2
if "%wolchoice%"==3 goto :GLOWS3
if "%wolchoice%"==4 goto :GLOWS4
if "%wolchoice%"==5 goto :GLOWS5
if "%wolchoice%"==6 goto :GLOWS6
if "%wolchoice%"==7 goto :GLOWS7
if "%wolchoice%"==8 goto :SERVER

:GLOWS1
wolcmd %GLOWS1% %GLOWS1IP% 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS2
wolcmd %GLOWS2% %GLOWS2IP% 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS3
wolcmd %GLOWS3% %GLOWS3IP% 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS4
wolcmd 20cf30a79321 131.94.44.103 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS5
ping yahoo.com
REM wolcmd 20cf30a7cd35 131.94.44.100 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS6
wolcmd %GLOWS6% %GLOWS6IP% 255.255.255.128 7
pause
goto :WOLmenu

:GLOWS7
wolcmd %GLOWS7% %GLOWS7IP% 255.255.255.128 7
pause
goto :WOLmenu

:SERVER
wolcmd %SERVER% %SERVERIP% 255.255.255.128 7
pause
goto :WOLmenu


[/CODE]

The script gives a simple menu, and based upon user input, it reads the MAC and IP from given variables, and invokes them into a program that send the magic WOL packet to the appropriate computer. From what I can tell, all is ok with the coding, but it's still not working. All I get is the usage prompt from the WOL program, as if the command was entered incorrectly.

Also, I attempted to change one of the computers to simply use a ping command when selected to test, but it simply gave me the same usage menu from the WOL tool.

Any ideas/comments/suggestions?

NOTE: The IP's have stars for security. The real script has the full IP.


See More: batch not running correctly

Report •


#1
November 15, 2010 at 07:16:39
have you tried using a different port?

Report •

#2
November 15, 2010 at 07:18:33
if i run the tool on its own in cmd, it works perfectly. It only gives an error when plugged into the batch script

Report •

#3
November 15, 2010 at 07:21:18
dumb question... you don't have the code and endcode tags in the actual batch right?

Report •

Related Solutions

#4
November 15, 2010 at 07:24:50
no. their only in this because I copied the post from another forum that used code tags. sorry about that.

Report •

#5
November 15, 2010 at 07:29:25
did you put the wolcmd executable in the system folder? If not, you would have to run the batch from the same directory that contains that program.

Report •

#6
November 15, 2010 at 07:31:31
i placed its folder in the path, so running wolcmd is the same as going to the directory.

Report •

#7
November 15, 2010 at 07:31:49
Have you tried the batch without all the set commands? Maybe that wolcmd program doesn't like variables?

Report •

#8
November 15, 2010 at 07:36:30
just tried it, and no change.

Thanks for helping with this, i really do appreciate it :-)


Report •

#9
November 15, 2010 at 07:38:28
no problem. I wish I had a better answer for you. I might have to try it later and let you know what I get.

Report •

#10
November 15, 2010 at 08:28:56
"All I get is the usage prompt"

Too bad we don't.

If we did, somebody might troubleshoot your script.


=====================================
Life is too important to be taken seriously.

M2


Report •

#11
November 15, 2010 at 08:33:26
http://www.depicus.com/wake-on-lan/...

^the website to get the wol tool, if you want to replicate the script step by step.


Report •

#12
November 15, 2010 at 08:39:36
Wake On Lan Command Line...

Usage: wolcmd [mac address] [ipaddress] [subnet mask] [port number]

i.e. wolcmd 009027a322fc 195.188.159.20 255.255.255.0 7

or wolcmd 009027a322fc depicus.com 255.255.255.0 7

Copyright www.depicus.com (Brian Slack) 1966-2005


Report •

#13
November 15, 2010 at 09:17:12
This will never resolve TRUE:

if "%wolchoice%"==1 goto :GLOWS1

this will:

if "%wolchoice%"=="1" goto :GLOWS1


=====================================
Life is too important to be taken seriously.

M2


Report •

#14
November 15, 2010 at 09:30:56
w00t, got it running. problem was the quotes around the user input.

thanks!


Report •

#15
November 15, 2010 at 09:35:30
You can save plety of typing and clutter and potential for error like this:

====================================
@echo off & setLocal EnableDELAYedeXpansion

set /p N=which? & goto :!N!

:1
echo 1
goto :eof

:2
echo 2


=====================================
Life is too important to be taken seriously.

M2


Report •


Ask Question