问题描述
我使用Notepad ++来编辑PowerShell文件,并希望能够从Notepad ++内部执行该文件。
如何设置? >
这使我有点小小,但我终于得到这个工作。 (我使用的是版本1.0,但这也应该在其他版本中工作。)
Notepad ++可以设置为运行命令,并为这些命令分配快捷方式,如下:
从菜单中,点击运行→运行
添加命令
保存命令,为其命名和快捷键。
下面是批处理文件的内容。我命名我的 NotepadRun.bat
,但你可以命名任何。
@echo off
GOTO%〜sx1
:.ps1
cd%〜d1%〜p1
powershell.exe。\%〜n1% 〜sx1
GOTO end
:.rb
ruby%〜f1
GOTO end
:.php
php%〜f1
GOTO end
:end
暂停
作为注意升级到Windows7和Powershell 2我发现一些问题,并已更新到传递一个ExecutionPolicy,以确保我可以运行我正在编辑的脚本。
<$ pre>
I am using Notepad++ to edit a PowerShell file and want to be able to execute that file from inside Notepad++.
How can I set that up?
It took me a little fiddling, but I finally got this working. (I am using version 1.0 but this should work in other versions as well.)
Notepad++ can be set up to run commands, and assign shortcuts to those commands, as follows:
From the menu, click Run → Run
Add the command
Save the command, giving it a name and a key shortcut.
Below are the contents of the batch file. I named mine NotepadRun.bat
, but you can name it whatever.
@echo off
GOTO %~sx1
:.ps1
cd "%~d1%~p1"
powershell.exe .\%~n1%~sx1
GOTO end
:.rb
ruby "%~f1"
GOTO end
:.php
php "%~f1"
GOTO end
:end
pause
As a note upgrading to Windows7 and Powershell 2 I found some Issues with this and have updated to passing in an ExecutionPolicy to ensure I can run the script I am editing.
:.ps1
cd "%~d1%~p1"
powershell -ExecutionPolicy Unrestricted -File "%~n1%~sx1"
GOTO end
这篇关于如何从记事本++执行PowerShell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!