简体   繁体   English

如何在命令提示符下创建特定命令的快捷方式?

[英]How to create a shortcut to a particular command in command prompt?

Is it possible to create something like a desktop shortcut that I could double click to run a particular command that I would normally type out in command prompt? 是否有可能创建类似桌面快捷方式的东西,我可以双击以运行我通常在命令提示符下输入的特定命令? Here is one that I want to make a shortcut of: 这是我想要的捷径:

C:\\Users\\jdave\\Documents\\Java>appletviewer ButtonExample.html

I asked this on Yahoo Answers because I thought it would be a little basic for Stack Overflow and one person said to create a batch file like so: 我在Yahoo Answers上问过这个问题,因为我觉得它对Stack Overflow来说有点基础,有人说要像这样创建一个批处理文件:

@echo off
start "C:\Users\jdave\Documents\Java>appletviewer ButtonExample.html"

I did this but all it does is open a command prompt window. 我做了这个,但它只是打开一个命令提示窗口。

Your batch file should look something like this: 您的批处理文件应如下所示:

@echo off
cd C:\Windows\System32\
start notepad.exe C:\Users\"user1"\test.txt

Replace the "user1" with your username or give the proper path to your application. 用您的用户名替换“user1”或提供应用程序的正确路径。

Make sure that appletviewer takes the type of parameter that you are passing it. 确保appletviewer采用您传递的参数类型。

你可以用它创建一个快捷方式

C:\Users\jdave\Documents\Java\appletviewer ButtonExample.html

Your command doesn't look correct, try this: 你的命令看起来不正确,试试这个:

C:\Users\jdave\Documents\Java\appletviewer GifExample.html

Ensure that appletviewer.exe exists in this location. 确保appletviewer.exe存在于此位置。

You need to set java bin directory in environment variable path. 您需要在环境变量路径中设置java bin目录。 Use following batch : 使用以下批次:

@echo off
cd  "C:\Users\jdave\Documents\Java"
appletviewer GifExample.html

Right-click on Desktop > New > Shortcut. 右键单击桌面>新建>快捷方式。 Enter Location 输入位置

appletviewer GifExample.html

Click Next, enter name of shortcut, click Finish. 单击“下一步”,输入快捷方式名称,单击“完成 You're done. 你完成了。

By the way, the > you see on the command prompt is not part of the command. 顺便说一句,在>你的命令提示符下看是不是命令的一部分。 The actual command starts after the > symbol. 实际命令 >符号后面开始。

Also, the 'appletviewer' program probably doesn't reside in C:\\Users\\jdave\\Documents\\Java . 此外,'appletviewer'程序可能不在 C:\\Users\\jdave\\Documents\\Java The above is correct if you can already run appletviewer from any folder in the command prompt. 如果您已经可以从命令提示符中的任何文件夹运行appletviewer,则上述操作是正确的。 If you do C:\\Users\\jdave\\Documents\\Java\\appletviewer GifExample.html it may not work at all! 如果您执行C:\\Users\\jdave\\Documents\\Java\\appletviewer GifExample.html它可能根本不起作用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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