+ Reply to Thread
Results 1 to 4 of 4

Thread: Calling .bat file problem...

  1. #1
    Barn Regular bryceowen is on a distinguished road bryceowen's Avatar
    Join Date
    Sep 2008
    Location
    Jacksonville, FL
    Posts
    93
    Rep Power
    4

    Calling .bat file problem...

    I wrote a script to backup some files for me automagically and to also call a .bat file that would backup my MySQL database.

    Well, the file copying works great, but for some reason, it doesn't call the .bat file like it's supposed to. When I run the script manually, it works exactly as it should, but when it runs at 1 AM like I asked, it borks.

    Here's the vbs:
    Code:
    dim dbcopy
    dim mysqlbackup
    dim foldername
    
    foldername="C:\backup\"&weekdayname(weekday(date()))
    set dbcopy=CreateObject("Scripting.FileSystemObject")
    if dbcopy.FolderExists(foldername) then
      dbcopy.DeleteFolder(foldername)
    end if
    dbcopy.CreateFolder(foldername)
    dbcopy.CopyFile "C:\Inetpub\wwwroot\_private\*.*", foldername
    
    set mysqlbackup=wscript.createobject("wscript.shell")
    mysqlbackup.run("sqlbackup.bat "&weekdayname(weekday(date())))
    
    And here's the contents of 'sqlbackup.bat':
    Code:
    @echo on
    mysqldump -uxxx -pxxx sales > c:\backup\%1\sales.sql
    
    As always, any assistance is greatly appreciated.

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Maybe it can't find sqlbackup.bat. Something about that line doesn't look right. See here: Run Method (Windows Script Host)
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Regular bryceowen is on a distinguished road bryceowen's Avatar
    Join Date
    Sep 2008
    Location
    Jacksonville, FL
    Posts
    93
    Rep Power
    4

    That's actually the same page I read when I wrote the script. As I said, the script runs flawlessly when I run it manually. I did, however, just add the full path to mysqlbackup.bat and scheduled it to run a couple minutes ago and it worked. So I guess the lesson here is, "Don't trust the computer to know where all the files are, even if they are in the same directory."

    Thank you, Murray!

  4. #4
    Windows Guru Nilpo is on a distinguished road Nilpo's Avatar
    Join Date
    Jul 2010
    Location
    Wake Forest, NC
    Posts
    68
    Real Name
    Robert Dunham
    Rep Power
    2

    Scheduled Tasks run from the system directory, not the script location.
    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!

+ Reply to Thread

Similar Threads

  1. CronTab problem: No input file specified.
    By grae.uk in forum PHP Development
    Replies: 4
    Last Post: February 25th, 2009, 07:19 AM
  2. calling javascript function from asp
    By guddu in forum ASP Development
    Replies: 8
    Last Post: November 19th, 2008, 02:48 PM
  3. calling function
    By guddu in forum ASP Development
    Replies: 3
    Last Post: November 5th, 2008, 09:34 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO