且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过Notepad ++外部命令将脚本文件放入控制台?

更新时间:2023-12-05 17:54:28

最后的代码行将把CD和脚本调用视为一个命令。然后与和& 分开应该会有所帮助。

The final code line would mean the CD and the script invocation being treated as one command. Separating then with && should help.

cmd /K cd $(CURRENT_DIRECTORY) && $(FILE_NAME)

但是,这将使CD执行命令。我不知道有什么方法可以输入命令但不能执行。

However, that would do the CD then execute the command. I do not know of any way to enter a command but not execute it.

一个糟糕的解决方案将使用下面的命令。您可以复制并粘贴echoed命令,然后添加所需的任何参数。在窗口上设置快速编辑模式将使复制和粘贴更快。

A poor solution would use the command below. You could copy and paste the echoed command then add in any parameters needed. Setting "Quick edit" mode on the window would make the copy and paste quicker.

cmd /K cd $(CURRENT_DIRECTORY) && ECHO $(FILE_NAME)






我采用了其他方式我自己的脚本的一种方法,尽管它们没有我需要输入的参数。编辑文件(但不使用Notepad ++,因为它会在文件退出之前覆盖文件):


I have adopted a different approach for my own scripts although they do not have parameters that I need to enter. Edit the file (but not with Notepad++ as it overwrites the file just before it exits):

C:\Users\AdrianHHH\AppData\Roaming\Notepad++\shortcuts.xml

我在< UserDefinedCommands> 部分:

<NotepadPlus>
    ... unchanged
    <UserDefinedCommands>
        ... unchanged
        <Command name="Open containing folder" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_DIRECTORY)</Command>
        <Command name="Open current dir cmd" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /K cd /d $(CURRENT_DIRECTORY)</Command>
        <Command name="Run as command" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /C &quot;cd /d $(CURRENT_DIRECTORY) &amp;&amp; $(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="Explorer with selection" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_WORD)</Command>
    </UserDefinedCommands>
    ... unchanged
</NotepadPlus>