mac_shinobi Posted October 18, 2012 Posted October 18, 2012 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
mac_shinobi Posted October 18, 2012 Author Posted October 18, 2012 bump - found this article but not being great with bat files not sure how to make it map the drive if it comes back with link is up command line - How to check if ping responded or not in a batch file - Stack Overflow
andy_b Posted October 18, 2012 Posted October 18, 2012 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
mac_shinobi Posted October 18, 2012 Author Posted October 18, 2012 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??
andy_b Posted October 18, 2012 Posted October 18, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now