Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file not working when double-clicked.  (Read 2182 times)

0 Members and 1 Guest are viewing this topic.

ituyeh

  • Guest
batch file not working when double-clicked.
« on: March 06, 2007, 10:18:25 PM »
I have a perl script that takes 2 arguments. The script connects to a database to retrive some data. I want to use batch file to call this script.

in my batch file, i have:
c:\perl\bin\perl myperl.pl arg1 arg2

Problem: if i manually type in the batch filename in the dos-prompt, the script runs perfectly. But if I just double click the batch file, on the popped up dos prompt window, I get an error saying access denied to connect to the database.

Can someone pls help? Thanks.

lordoftheplat



    Hopeful

  • teh god.
  • Thanked: 1
    Re: batch file not working when double-clicked.
    « Reply #1 on: March 07, 2007, 06:00:52 AM »
    @echo off
    echo.
    call c:\perl\bin\perl myperl.pl arg1 arg2
    pause
    exit


    save that as a batch file
    zepperblood.deviantart.com

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: batch file not working when double-clicked.
    « Reply #2 on: March 07, 2007, 06:43:43 AM »
    I think its better not to have the pause:

    @echo off
    echo.
    call c:\perl\bin\perl myperl.pl arg1 arg2  
    pause
    exit

    lordoftheplat



      Hopeful

    • teh god.
    • Thanked: 1
      Re: batch file not working when double-clicked.
      « Reply #3 on: March 07, 2007, 07:48:37 AM »
      why no pause? u can see what errors u have when u put pause there
      « Last Edit: March 07, 2007, 07:48:57 AM by lordoftheplat »
      zepperblood.deviantart.com

      ituyeh

      • Guest
      Re: batch file not working when double-clicked.
      « Reply #4 on: March 07, 2007, 01:28:25 PM »
      Hi al.. thank you for responding.. i found out the cause.. i have to add set USER=myUserName for it to work.

      Again, thanks for the help.