I'm used to using a Mac, and I've written a program for my Mac that I now need to implement on a PC. On a mac, I run it through a shell file, using the following code:
cd ./desktop/Program
./MyProgram
./clearFiles
I've tried entering
cd ./desktop/Program^
./MyProgram^
./clearFiles
and saving it as both a .bat and a .cmd file but I can't get either to work. Is there a similar format to .sh I could use on Windows 7 to do the same thing? I want to be able to execute 3 commands in Command Prompt with just one click.
Microsoft offers a command-line reference.
It looks like you want to set current directory to a subdirectory on desktop of user containing your applications MyProgram
and clearFiles
which are called one after the other.
A batch file to do this would be:
cd /D "%USERPROFILE%\Desktop\Program"
MyProgram.exe
clearFiles.exe
As a single line the command line would be:
cd /D "%USERPROFILE%\Desktop\Program" & MyProgram.exe & clearFiles.exe
See Conditional Execution on SS64 containing even more information than provided by Microsoft about command processor of Windows.
Opening on Windows a command prompt window and executing help
shows a list of commands. Running a command like cd with parameter /?
in command prompt window results in getting help for this command displayed which can be multiple display pages like for commands for or set.
%USERPROFILE%
references the environment variable USERPROFILE
containing path to user profiles directory (home directory of user on *nix).