+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, WOL Bat or VBS Script in Coding and Web Development; Hi Found this : http://www.edugeek.net/forums/window...utility-2.html Basically need a script put together, am using this utility : Wake-on-LAN [ MATCODE.com ] ...
  1. #1

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,756
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365

    WOL Bat or VBS Script

    Hi

    Found this :

    Dell WOL Utility

    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

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,756
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    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

  3. #3

    Join Date
    Apr 2007
    Location
    Birmingham
    Posts
    142
    Thank Post
    6
    Thanked 45 Times in 39 Posts
    Rep Power
    22
    Not fool proof, but seems to work ok

    Code:
    @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

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,756
    Thank Post
    3,265
    Thanked 1,052 Times in 973 Posts
    Rep Power
    365
    Quote Originally Posted by andy_b View Post
    Not fool proof, but seems to work ok

    Code:
    @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??

  5. #5

    Join Date
    Apr 2007
    Location
    Birmingham
    Posts
    142
    Thank Post
    6
    Thanked 45 Times in 39 Posts
    Rep Power
    22
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 7
    Last Post: 16th December 2011, 05:54 AM
  2. VB script template
    By ajbritton in forum Coding
    Replies: 6
    Last Post: 27th December 2006, 09:16 PM
  3. Replies: 4
    Last Post: 25th December 2006, 09:15 PM
  4. VB Script ti check for folder and then copy contents to PC
    By tosca925 in forum How do you do....it?
    Replies: 4
    Last Post: 2nd October 2006, 08:15 PM
  5. VBS script for prestaging computers anyone?
    By ChrisH in forum Scripts
    Replies: 7
    Last Post: 23rd June 2006, 09:59 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •