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

Author Topic: Btch with exe parameter  (Read 4147 times)

0 Members and 1 Guest are viewing this topic.

kepler

    Topic Starter


    Starter

    • Experience: Experienced
    • OS: Windows 7
    Btch with exe parameter
    « on: June 03, 2017, 07:16:02 AM »
    Good morning

    I'm making a batch file for windows, but I want it to receive several parameters and output the result to a file.

    Is this the right way to write the batch file?

    %1 %2 %3 %4 %5 %6 %7 %8 %9 > results.txt

    where %1 is the exe? Doesn't seem to work very well when integrated within othe apps...

    Regards

    Kepler

    strollin



      Adviser
    • Thanked: 84
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 10
    Re: Btch with exe parameter
    « Reply #1 on: June 03, 2017, 11:52:13 AM »
    Generally speaking, you have the right idea.  You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output.  There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned.  Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.

    Can you give more specific examples of what you are trying to do?

    Salmon Trout

    • Guest
    Re: Btch with exe parameter
    « Reply #2 on: June 03, 2017, 02:08:31 PM »
    Can you give more specific examples of what you are trying to do?

    ++1

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Btch with exe parameter
    « Reply #3 on: June 03, 2017, 03:25:03 PM »
    shift

    kepler

      Topic Starter


      Starter

      • Experience: Experienced
      • OS: Windows 7
      Re: Btch with exe parameter
      « Reply #4 on: June 03, 2017, 11:19:05 PM »
      Generally speaking, you have the right idea.  You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output.  There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned.  Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work.

      Can you give more specific examples of what you are trying to do?

      Good day

      I'm sorry for the late reply. I wasn't able to check my email yesterday...

      The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.

      So, for instance, I would call;

      mybatch.bat myexe.exe param1 param2

      would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):

      myexe.exe param1 param2 > results.txt

      The exe would be a "parameter" to the batch, but to run.

      Kind regards,

      Kepler



      Salmon Trout

      • Guest
      Re: Btch with exe parameter
      « Reply #5 on: June 04, 2017, 01:19:38 AM »
      The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.

      So, for instance, I would call;

      mybatch.bat myexe.exe param1 param2

      would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt):

      myexe.exe param1 param2 > results.txt

      That might work, provided the exe was written to accept command line parameters, and it writes text output to the console (to STDOUT if you want to get technical.) A quick question: why don't you just try it?

      kepler

        Topic Starter


        Starter

        • Experience: Experienced
        • OS: Windows 7
        Re: Btch with exe parameter
        « Reply #6 on: June 04, 2017, 02:02:46 AM »
        Hi

        No, it wasn't working.... because the bat file was in utf8!!!... Jesus... I'm sorry for the trouble.

        Have a nice weekend.

        Kepler