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. Bat file

    in Windows 10 Gaming
    Bat file: I have a bat fileI am improving it bit by bit till I have reached But not i have added a warning to it before a commandI now want to make that line font size Bigger than the others How can I do that ??So here is the Batch file content@ECHO OFF echo...
  3. Bat file

    in Windows 10 Software and Apps
    Bat file: I have a bat fileI am improving it bit by bit till I have reached But not i have added a warning to it before a commandI now want to make that line font size Bigger than the others How can I do that ??So here is the Batch file content@ECHO OFF echo...
  4. .bat files

    in Windows 10 Network and Sharing
    .bat files: So i am trying to make a minecraft server and need to open a .bat file but i keep getting a error saying "This app can not run on this pc" But it worked a month ago i need a solution please....
  5. Bat file

    in Windows 10 Ask Insider
    Bat file: Good morning/evening/night, I wanted to create a batch file or an exe that can change options inside the gui of an application (the application is cisco webex) (if you are familliar with webex i want to change the audio or turn it to music mode witha batch file) but i am...
  6. Pass an argument from a .bat file to PowerShell script

    in Windows 10 Support
    Pass an argument from a .bat file to PowerShell script: I have subscribed to a push notification service in order to be able to send push notifications to my phone. Here is the PowerShell script: Code: $uri = "https://api.pushover.net/1/messages.json" $parameters = @{ token = "token" user = "user" message = "Push Message" }...
  7. 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...
  8. .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.....
  9. 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"
  10. 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...