Jump to content

Recommended Posts

Posted

Hi

 

Found this :

 

http://www.edugeek.net/forums/windows/38429-dell-wol-utility-2.html

 

Basically need a script put together, am using this utility : Wake-on-LAN [ MATCODE.com ]

 

Script requirements

 

1. Send magic packet to my computers mac address ( script and the mc-wol util will be stored on my memory stick so want it to just run the mc-wol utility without any drive letters if possible )

2. Test to see if my computer has woken up ie by pinging the computer name as obviously the ip address of my pc will change from day to day.

3. If there is a ping reply then I need it to map a path using my domain admin credentials and map it to the drive letter Y assuming said drive letter is not in use, if it is then prompt for a letter to use and map the drive using that letter.

 

Thanks

Posted

Not fool proof, but seems to work ok :)

 

@echo off

REM setup variables
set /a count=0
set state=down
set defaultLetter=y
set delay=0

REM customise these variables
set machineName=
set sharedFolder=
set macAddress=

:wol
REM Send Magic Packet
cls
MC-WOL.EXE %macAddress%
ping -n %delay% 127.0.0.1 >nul 
ping -n %delay% 127.0.0.1 >nul 

:loop
REM Try to ping machine, if not found repeat 10 times every %delay% seconds then give up
for /f "tokens=5,7" %%a in ('ping -n 1 %machineName%') do (if "x%%a"=="xReceived" if "x%%b"=="x1," set state=up)
If "%state%"=="up" goto mapdrive
set /a count+=1
If %count%==10 goto exit
ping -n %delay% 127.0.0.1 >nul
goto :loop


:mapdrive
REM Map drive, prompt if letter already used
echo.
echo.
IF EXIST %defaultletter%: (

   set /p defaultLetter="Enter the required drive letter and press enter > "
)
net use "%defaultLetter%:" "\\%machineName%\%sharedFolder%"

:exit

Posted
Not fool proof, but seems to work ok :)

 

@echo off

REM setup variables
set /a count=0
set state=down
set defaultLetter=y
set delay=0

REM customise these variables
set machineName=
set sharedFolder=
set macAddress=

:wol
REM Send Magic Packet
cls
MC-WOL.EXE %macAddress%
ping -n %delay% 127.0.0.1 >nul 
ping -n %delay% 127.0.0.1 >nul 

:loop
REM Try to ping machine, if not found repeat 10 times every %delay% seconds then give up
for /f "tokens=5,7" %%a in ('ping -n 1 %machineName%') do (if "x%%a"=="xReceived" if "x%%b"=="x1," set state=up)
If "%state%"=="up" goto mapdrive
set /a count+=1
If %count%==10 goto exit
ping -n %delay% 127.0.0.1 >nul
goto :loop


:mapdrive
REM Map drive, prompt if letter already used
echo.
echo.
IF EXIST %defaultletter%: (

   set /p defaultLetter="Enter the required drive letter and press enter > "
)
net use "%defaultLetter%:" "\\%machineName%\%sharedFolder%"

:exit

 

What about domain admin logon credentials??

Posted

oops.

 

net use "%defaultLetter%:" "\\%machineName%\%sharedFolder%" /user:domain\username

 

this will prompt for password

 

or

 

net use "%defaultLetter%:" "\\%machineName%\%sharedFolder%" /user:domain\username password

 

if u feeling brave :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...