Passing parameters in a bat file


  1. Posts : 57
    Windows 10
       #1

    Passing parameters in a bat file


    I am trying to run a bat file from a desktop shortcut.
    If I run it from DOS it works fine.
    If I try to run it from a desktop shortcut, I can not pass the parameter inside the bat file.
    See attached for the example of the bat file.
    The first part works (from the DOS prompt).
    The second part does not work trying to pass the parameters.
    I got the results from the web.
    Passing parameters in a bat file Attached Files
      My Computer


  2. Posts : 456
    Windows 10
       #2

    What does the batch file do?
      My Computer


  3. Posts : 57
    Windows 10
    Thread Starter
       #3

    Passing parameters in a bat file


    It runs several sub programs and renames them when finished.
      My Computer


  4. Posts : 456
    Windows 10
       #4

    Can you give an example and how it's supposed to work.

    What is passed as an argument?

    Like:

    Batch.bat SomeProgram.exe

    and then it renames the program like SomeProgram2.exe

    Can you put only the code inside the batch....
      My Computer


  5. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #5

    Please post screenshots of
    1 The Command window showing the command you use to run the batch file
    2 The shortcut properties

    Please post the batch file.

    Denis
      My Computer


  6. Posts : 57
    Windows 10
    Thread Starter
       #6

    Passing parameters in a bat file


    I am enclosing the bat file and a text file that shows the results from DOS.
    and the results when I try to run the program from a shortcut on the Desktop.
    Passing parameters in a bat file Attached Files
      My Computer


  7. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #7

    I notice that you did not provide the screenshot I asked for or the shortcut properties.

    GUPPY said:
    If I run it from DOS it works fine
    No, it cannot. The batch file contains numerous errors and is incapable of running correctly.

    I think this batch file was scanned from an image but was not then proof-read.

    Denis
    Last edited by Try3; 18 Apr 2020 at 14:02.
      My Computer


  8. Posts : 57
    Windows 10
    Thread Starter
       #8

    Passing parameters in a bat file


    I open a dos prompt, change the directory to G:
    Then change the directory to G:\batch_file
    I type Tryit and enter a date after it ie TRYIT 20191220.TXT
    The bat file takes off the .txt and continues on correctly.

    I am enclosing the BAT file (TRYIT.BAT) and the log file ("log file run from dos.txt") .
    I did not scan the bat file image, just loaded it.
    The Bat file is run from my"G" drive with different directories on the "G" drive.
    That probably accounts for the numerous errors you received.
    I would like the TRYIT.BAT command file to run from the desktop and not from dos.
    Passing parameters in a bat file Attached Files
    Last edited by Gladiator; 23 Apr 2020 at 12:09.
      My Computer


  9. Posts : 16,955
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #9

    Try3 said:
    Please post screenshots of
    1 The Command window showing the command you use to run the batch file
    2 The shortcut properties
    GUPPY said:
    I would like the TRYIT.BAT command file to run from the desktop and not from dos.
    Try3 said:
    I notice that you did not provide the screenshot I asked for or the shortcut properties.
    This is the one bit I can help you with.



    GUPPY said:
    I open a dos prompt, change the directory to G:
    Then change the directory to G:\batch_file
    I type Tryit and enter a date after it ie TRYIT 20191220.TXT
    The bat file takes off the .txt and continues on correctly.
    It does not run "correctly".
    It cannot run "correctly".
    The first line generates an error. I don't know why you kept working on this batch file beyond line 1 when that was not written correctly.
    The second line is nonsensical.
    The third echo command is nonsensical.
    The Start command lines are so nonsensical that I thought they could only be created by very poor image OCR.
    The :CVT_CONT line is not used. Perhaps this indicates that the code has been extracted from somewhere else.

    The Bat file is run from my"G" drive with different directories on the "G" drive.
    That probably accounts for the numerous errors you received.
    I did not run it. I read it.
    I suggest that you try the Stackoverflow forum - batch file questions - Stack Overflow
    Last edited by Try3; 24 Apr 2020 at 04:23.
      My Computer


  10. Posts : 14,022
    Win10 Pro and Home, Win11 Pro and Home, Win7, Linux Mint
       #10

    To add, DOS is not as we used to use/know it although many of the DOS commands can be run in the Command Prompt. Working in the Prompt window can allow commands to be run such as dir /o/p [organized and pause at each screenful] to get a list of files in a folder [renamed from Directory of early versions of DOS and Windows]. Win95 was the beginning of the merging of DOS and the GUI into one installation instead of 2 comprising DOS followed by the GUI.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:15.
Find Us




Windows 10 Forums