joshft91
joshft91

Reputation: 1885

Run multiple commands sequentially

I'll try to keep this short...I'm new to using batch files, so bear with me. But here's what I'd like to happen:

Here's what I've done so far:

cmd.exe /k "cd %USERPROFILE%\Desktop"

Now I'd like to execute a file that's in the desktop directory. I was reading that you could something chain commands together with & or && (cmd.exe /k "cd %USERPROFILE%\Desktop" && "test.exe --config=test.txt") but I haven't had any luck.

How would I go about adding another command such as test.exe --config=test.txt to be run after I changed to the desktop directory?

Thanks.

Upvotes: 2

Views: 7658

Answers (2)

Matt Williamson
Matt Williamson

Reputation: 7095

Try this. Add the following to a file and name it runtest.cmd.

@echo off
setlocal

cd /d "%userprofile%/desktop"
test.exe --config=test.txt

Upvotes: 0

Jeremy Whitcher
Jeremy Whitcher

Reputation: 721

Try removing quotes at the end of the first command and the beginning of the second command. Something like: cmd.exe /k "cd %USERPROFILE%\Desktop && test.exe --config=test.txt"

This just worked for me. cmd /k "cd %USERPROFILE%\Desktop && FileCrc.exe"

Upvotes: 3

Related Questions