Windows 10: Passing parameters in a bat file

Discus and support Passing parameters in a bat file in Windows 10 Support to solve the problem; 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... Discussion in 'Windows 10 Support' started by GUPPY, Apr 17, 2020.

  1. GUPPY Win User

    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.

    :)
     
    GUPPY, Apr 17, 2020
    #1
  2. GUPPY Win User

    Pass partial parameter in bat file

    I have about 200 files
    examples:
    20200101 FILE10.TXT
    20200102 FILE10.TXT
    20200103 FILE10.TXT
    20200104 FILE10.TXT

    I need a way to accept only the first 8 positions in a bat file and copy the whole file to another directory.
    If enter 20200101 and it will pass the file 20200101 FILE10.TXT to another directory.
    After it is passed it has to be renamed to update.txt to be run from inside another bat file.
    Presently, I have to manually copy each file to the other directory.
     
    GUPPY, Apr 17, 2020
    #2
  3. jimbo45 Win User
    Pass partial parameter in bat file

    Hi there
    @GUPPY

    this would be known as a substring function in most programming languages --however it works in a windows batch cmd :

    %variable:~num_chars_to_skip, -num_chars_to_keep%

    e.g SET _test=123456789abcdef0

    for example to extract only the first 5 characters of variable _test

    SET _result=%_test:~0,5%
    ECHO %_result% =12345

    Now you need CONCATENATE type of function (add the .txt to the first variable where you've extracted the 8 chars)

    e.g

    @echo off
    set myvar="the list: "
    for /r %%i in (*.doc) DO call :concat %%i
    echo %myvar%
    goto :eof

    :concat
    set myvar=%myvar% %1;
    goto :eof

    "Seemples !!!"

    Modify for your directories -- and include copy / other funcs you need..
    Cheers
    jimbo
     
    jimbo45, Apr 17, 2020
    #3
  4. ryanly Win User

    Passing parameters in a bat file

    GPU-Z what command line parameter ?

    Current /? (-?) or / help (-help) parameter is invalid
     
    ryanly, Apr 17, 2020
    #4
Thema:

Passing parameters in a bat file

Loading...
  1. Passing parameters in a bat file - Similar Threads - Passing parameters bat

  2. Pass partial parameter in bat file

    in Windows 10 Support
    Pass partial parameter in bat file: I have about 200 files examples: 20200101 FILE10.TXT 20200102 FILE10.TXT 20200103 FILE10.TXT 20200104 FILE10.TXT I need a way to accept only the first 8 positions in a bat file and copy the whole file to another directory. If enter 20200101 and it will pass the file...
  3. Wait in .bat file

    in Windows 10 Ask Insider
    Wait in .bat file: How do I insert a wait command? I have several commands in this .bat file. I am finding some error out if they go too quickly. So here is what I would like to do. CMD 1 <Wait 5 Seconds> CMD 2 <Wait 5 Seconds> CMD 3 I do not know if this matters or not, but the...
  4. .bat file

    in Windows 10 Customization
    .bat file: I have .bat file it is not working in my new PC when I double click on it. but it was working in my old PC. could your please support how to associate .bat file in windows 10? Kindly looking for your support and reply in this regards. Thanks.....
  5. invalid INF passed as parameter

    in Windows 10 Network and Sharing
    invalid INF passed as parameter: hello i decided to update my laptop drivers but when i start the command thingy it says invalid INF passed as parameter and it restarts help https://answers.microsoft.com/en-us/windows/forum/all/invalid-inf-passed-as-parameter/ab19feaa-4fc0-4294-8fd8-0b7481b6d07e"
  6. .bat files changed?

    in Windows 10 Ask Insider
    .bat files changed?: Greetings. Regarding Windows 10. I have a .bat file that I've used for... well, since forever. It rarely changes and it hasn't changed in months. Despite running quite fine in its current incarnation for some months now it's quite recently it's began throwing the error:...
  7. Windows .bat File

    in Windows 10 Network and Sharing
    Windows .bat File: I have a .bat file on a pc that is supposed to get and send a file to and from a server. This .bat file is working properly when I run it on the pc but will not when trying to run it through a 3rd party software. there have been no errors, the .bat file will start to run but...
  8. Passing a parameter to a batch file for code signing

    in Windows 10 Network and Sharing
    Passing a parameter to a batch file for code signing: I am using MS Access and would like to pass an exe name to my code signing cert batch file. Been trying to figure this one out, but cannot get there. I created a batch file called. SignFile.bat. It contains everything I need to sign the file, but I need to pass the exe...
  9. Help with a .bat file.

    in Windows 10 Support
    Help with a .bat file.: I have this .bat file that I've been messing around with: [img] I got it to open the Windows Update interface: [img] However, I need the .bat file to go a step further and auto click the Check for updates button circled in orange. Can someone help me to finish...
  10. problem saving .bat file

    in Windows 10 Support
    problem saving .bat file: In Win 10, want to save .bat file in a Program directory. Downloaded a program in a zip file and unzipped it to a Program Files (x86) folder. This folder has other .bat files but one was missing. Now have it but cannot save it in the folder. I am the owner of the folder. 69008