Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts

    Drag on BAT file

    I dint know where to post this but here is a really cool thing i just made. Let me start by telling you what it does and why it does it.

    I am always having to share files with people especially players from my hl2dm gaming clan. Most of whom are on MSN. If they are on MSN its very cool because I can literally drag a file into the message box and it automatically offers a d/l link for the recipient to D/l. Which is cool

    However if a user hasn't got any MSN installed i have to find a different way to upload files to them. This is how i would of done this (using WAMP).
    1. find file.
    2. Copy file.
    3. goto c:\WAMP\WWW\send
    4. paste file into send
    5. goto CMD
    6. do IPCONFIG
    7. Copy the IP address
    8. Paste somewhere
    9. pretend to rename file so i can copy file name.
    10. Paste that after IP part.
    11. Copy whole thing and give to user.

    Thats 11 steps to bordem.

    So being the brainiac i am i decide to develop a drag and drop program. Its a simple BAT file that sits on my desktop and i can drag a file on to it. The batch then does the following
    1. Start WAMP
    2. Start services
    3. Copy dragged file to c:\wamp\www\send
    4. Output the download URL

    This way all i have to do is drag my file onto the BAT program and it automatically starts wamp and creates a download link to that file. Pretty cool hey?

    So heres the codes and instructions for installation
    1. create a BAT file on your desktop i named mine "auto_up_tool.bat"
    2. right click and edit
    3. Insert the codes below and save

    Code:
    cd c:\wamp
    START wampserver.exe 
    NET START wampapache
    NET START wampmysqld
    START firefox localhost/send?file=%1
    exit
    4. If you haven't already got it Download http://www.wampserver.com/en/ and install it.

    5. Now we have to make a PHP script to handle the request sent by the BAT file.

    6. goto c:\WAMP\WWW and create a folder called send make sure this has full read permissions and that system has write permissions.

    7. Go into your new send folder and create a file called index.php

    8 right click index.php and edit.

    9 Insert these codes

    PHP Code:
    <?PHP
     
     $the_file
    =NULL;
     
    $file=$_GET['file'];
     
    $file=str_replace(chr(92).chr(92), chr(92), $file);

     echo 
    $file.' <br /> Was the file to be sent<br />copying file';

        
    $RL_array=explode(chr(92), $file);
        
    $the_file=$RL_array[sizeof($RL_array)-1];
        
    $URL='copy "'.$file.'" "C:'.chr(92).'wamp'.chr(92).'www'.chr(92).'send'.chr(92).$the_file.'"';
        
    $moved=shell_exec($URL);
        
    $server_ip=shell_exec('ipconfig.exe | find "IP Address" | find /v " 0.0.0.0"'); 
        
        
    preg_match'/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/'$server_ip $ip );  
        
     echo 
    '<br />
             Here is the download link
            <br /> <a href="http://'
    .$ip[0].'/send/'.$the_file.'" >http://'.$ip[0].'/send/'.$the_file.'</a>';

    ?>
    Now go back to desktop and test it. drag a file on to the BAT file and watch it. HF
    Last edited by timgolding; 08-04-2007 at 03:45 PM.
    You can not say you know how to do something, until you can teach it to someone else.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    I was getting a problem with the returning the IP of the machine, it was returning as localhost, so i have produced some code to rectify this problem that should work on any windows machine. See the first post for these changes
    Last edited by timgolding; 08-04-2007 at 03:36 PM.
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    I have just dowloaded the latest version of WAMP and found that the application launchers filename has changed. To rectify this change

    Code:
    cd c:\wamp
    START wampserver.exe 
    NET START wampapache
    NET START wampmysqld
    START firefox localhost/send?file=%1
    exit
    for

    Code:
    cd c:\wamp
    START wampmanager.exe 
    NET START wampapache
    NET START wampmysqld
    START firefox localhost/send?file=%1
    exit
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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