How can I pass command line arguments to a program in a Windows batch file?

Jonathan

I'm trying to do this :

cd C:\Users\Public
%1 /s

Where %1 is the name of and executable that changes based on a where it's being executed, but is otherwise identical. The issue is that the /s is being seen as a command or program and not an argument to the executable passed in %1. Is what I'm trying to do possible? If so, what's the syntax?

Jonathan

Thanks for all your help guys. I looked at the documentation and your comments and, though I'm still completely unsure of how this is actually supposed to work, I got it working sensibly. Here's the solution I came up with:

"%~1" /s

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How I can I start a powershell command line from a batch file and enforce it to stay open?

분류에서Dev

How to convert a windows batch file into a signle line "cmd /c" command?

분류에서Dev

How can I pass parameter in Talend exported job, through command line or bash script file?

분류에서Dev

How can I turn on File and Printer sharing, and the Firewall from the Windows command line

분류에서Dev

Can I make a batch file that sets up a https proxy for IE without showing command line or window?

분류에서Dev

How can I create a file with a specific size from a command line?

분류에서Dev

How can I run a specific line as a command in a text file?

분류에서Dev

How do I run a command line program as Administrator under Windows 7?

분류에서Dev

How can I detect the first instance of a command-line Dart program to start?

분류에서Dev

How can I call a batch file within another batch file?

분류에서Dev

How to make a batch file to use Flex command line debugger?

분류에서Dev

Get raw arguments or command in batch file

분류에서Dev

How to pass paramaters like unix into windows batch file

분류에서Dev

how to get all the arguments in a command captured in a windows .bat file

분류에서Dev

In a Windows batch file, how to FOR /F with a command having multiple quoted strings

분류에서Dev

How Can I tell if the current user is Admin from Windows Command Line

분류에서Dev

How to correctly pass arguments to a function? [batch]

분류에서Dev

In windows, can I redirect stdout to a (named) pipe in command line?

분류에서Dev

How can I save the last command to a file?

분류에서Dev

How do you create an empty file from the command line in Windows

분류에서Dev

Pass variable to filename in Windows FOR / DO Batch File

분류에서Dev

How to pass arguments when calling `source` command

분류에서Dev

How to give python command line arguments from command line mode

분류에서Dev

How do I copy the directory and its folders in windows command line?

분류에서Dev

Can't pass values via command line

분류에서Dev

How can i resolve the path laocation in batch file

분류에서Dev

How can I run a batch file with a loop as a scheduled task?

분류에서Dev

How can I extract text before a character or string in a batch file?

분류에서Dev

How can I preview HTML documents from the command line?

Related 관련 기사

  1. 1

    How I can I start a powershell command line from a batch file and enforce it to stay open?

  2. 2

    How to convert a windows batch file into a signle line "cmd /c" command?

  3. 3

    How can I pass parameter in Talend exported job, through command line or bash script file?

  4. 4

    How can I turn on File and Printer sharing, and the Firewall from the Windows command line

  5. 5

    Can I make a batch file that sets up a https proxy for IE without showing command line or window?

  6. 6

    How can I create a file with a specific size from a command line?

  7. 7

    How can I run a specific line as a command in a text file?

  8. 8

    How do I run a command line program as Administrator under Windows 7?

  9. 9

    How can I detect the first instance of a command-line Dart program to start?

  10. 10

    How can I call a batch file within another batch file?

  11. 11

    How to make a batch file to use Flex command line debugger?

  12. 12

    Get raw arguments or command in batch file

  13. 13

    How to pass paramaters like unix into windows batch file

  14. 14

    how to get all the arguments in a command captured in a windows .bat file

  15. 15

    In a Windows batch file, how to FOR /F with a command having multiple quoted strings

  16. 16

    How Can I tell if the current user is Admin from Windows Command Line

  17. 17

    How to correctly pass arguments to a function? [batch]

  18. 18

    In windows, can I redirect stdout to a (named) pipe in command line?

  19. 19

    How can I save the last command to a file?

  20. 20

    How do you create an empty file from the command line in Windows

  21. 21

    Pass variable to filename in Windows FOR / DO Batch File

  22. 22

    How to pass arguments when calling `source` command

  23. 23

    How to give python command line arguments from command line mode

  24. 24

    How do I copy the directory and its folders in windows command line?

  25. 25

    Can't pass values via command line

  26. 26

    How can i resolve the path laocation in batch file

  27. 27

    How can I run a batch file with a loop as a scheduled task?

  28. 28

    How can I extract text before a character or string in a batch file?

  29. 29

    How can I preview HTML documents from the command line?

뜨겁다태그

보관