简体   繁体   中英

Similar to .sh on Windows 7

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM