<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; Run Here - настройка собственных команд контекстного меню каталогов]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15581</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15581&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Run Here - настройка собственных команд контекстного меню каталогов».]]></description>
		<lastBuildDate>Sat, 08 Aug 2020 07:11:41 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Run Here - настройка собственных команд контекстного меню каталогов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=141537#p141537</link>
			<description><![CDATA[<p>Пара незначительных исправлений:</p><p>-- запретил в тексте меню символ &quot;\&quot;<br />-- небольшие косметические изменения</p>]]></description>
			<author><![CDATA[null@example.com (Rumata)]]></author>
			<pubDate>Sat, 08 Aug 2020 07:11:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=141537#p141537</guid>
		</item>
		<item>
			<title><![CDATA[Run Here - настройка собственных команд контекстного меню каталогов]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=141523#p141523</link>
			<description><![CDATA[<p>Это маленький и не очень сложный, но достаточно гибкий скрипт для управления собственными командами в контекстном меню каталогов.</p><p>Разработан скрипт достаточно давно. С его помощью я создал несколько пунктов меню для запуска в заданном каталоге, например, &quot;Run Cygwin Here&quot;, &quot;Run Cmd Here&quot;. Недавно я включил поддержку создания иконок меню.</p><p>Поддерживает следующие ключи:</p><div class="codebox"><pre><code>
run-here [/A] /I &quot;menu&quot; [/K iconfile] [/NO-CHECK] command [arguments]
run-here [/A] /U &quot;menu&quot;
run-here [/A] /S &quot;menu&quot;
</code></pre></div><div class="quotebox"><blockquote><p>menu - Пункт меню, который появится в контекстном меню<br />command - команда, которая будет выполнена<br />arguments - Необязательные аргументы для команды. По умолчанию, если не указано, передается %V, то есть текущий каталог</p><p>/A - Применить для всех пользователей. По умолчанию - только для текущего<br />/I - Установить пункт меню<br />/U - Удалить пункт меню<br />/S - Показать для данного пункта меню записи из реестра<br />/K - Указать иконку пункта меню (файл или ресурс иконки)<br />/NO-CHECK - Не проверять путь до команды при инсталляции</p></blockquote></div><p>Вот некоторые рабочие примеры.</p><p>Добавить PowerShell:</p><div class="codebox"><pre><code>
run-here /i &quot;Run PowerShell Here&quot; /k powershell.exe powershell.exe -NoExit -Command Set-Location -LiteralPath &#039;%V&#039;
</code></pre></div><p>Аналогично можно установить, например, FAR (здесь надо указать настоящий путь до файла, так как он расположен на вашей системе):</p><div class="codebox"><pre><code>
run-here /i &quot;Run FAR3 Here&quot; C:\Правильный\путь\до\Far.exe &quot;%V&quot;
</code></pre></div><p>Критика и предложения приветствуются и обсуждаются.</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Исходный код</div><div class="fancy_spoiler"><p>Здесь последняя версия скрипта на момент на писания. Самую свежую версию можно также найти по адресу: <a href="https://github.com/ildar-shaimordanov/cmd.scripts/blob/master/run-here.bat">https://github.com/ildar-shaimordanov/c … n-here.bat</a>.</p><div class="codebox"><pre><code>
@echo off

setlocal

if /i &quot;%~1&quot; == &quot;&quot; goto :run_help

:: See also
:: https://www.howtogeek.com/165268/how-to-add-open-powershell-here-to-the-context-menu-in-windows/
:: https://www.tenforums.com/tutorials/60175-open-powershell-window-here-context-menu-add-windows-10-a.html
:: https://gist.github.com/davecan/f3045266aa9e3441211ab55f9db70c2b

:: Current user
:: HKEY_CURRENT_USER\Software\Classes\Drive\shell\&lt;menu&gt;\command
:: HKEY_CURRENT_USER\Software\Classes\Directory\shell\&lt;menu&gt;\command
:: HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\&lt;menu&gt;\command
set &quot;run_rootkey=HKEY_CURRENT_USER&quot;

:: All users
:: HKEY_LOCAL_MACHINE\Software\Classes\Drive\shell\&lt;menu&gt;\command
:: HKEY_LOCAL_MACHINE\Software\Classes\Directory\shell\&lt;menu&gt;\command
:: HKEY_LOCAL_MACHINE\Software\Classes\Directory\Background\shell\&lt;menu&gt;\command
if /i &quot;%~1&quot; == &quot;/A&quot; (
	set &quot;run_rootkey=HKEY_LOCAL_MACHINE&quot;
	shift
)

set &quot;run_classkey=%run_rootkey%\Software\Classes&quot;

:: /I, /U or /S
set &quot;run_action=%~1&quot;
shift

:: &quot;menu&quot;
set &quot;run_menu=%~1&quot;
shift

if not defined run_menu (
	&gt;&amp;2 echo:Menu not declared
	goto :run_help
)

if not &quot;%run_menu%&quot; == &quot;%run_menu:\=%&quot; (
	&gt;&amp;2 echo:Incorrect menu: %run_menu%
	goto :EOF
)

set &quot;run_subkey_list=Drive Directory Directory\Background&quot;

if /i &quot;%run_action%&quot; == &quot;/I&quot; goto :run_install
if /i &quot;%run_action%&quot; == &quot;/U&quot; goto :run_uninstall
if /i &quot;%run_action%&quot; == &quot;/S&quot; goto :run_show

&gt;&amp;2 echo:Unknown action: %run_action%
goto :run_help


:run_install
if /i &quot;%run_menu%&quot; == &quot;cmd&quot; goto :run_forbidden

:: [/K iconfile]
set &quot;run_iconfile=&quot;
if /i &quot;%~1&quot; == &quot;/K&quot; (
	set &quot;run_iconfile=%~2&quot;
	shift
	shift
)

:: [/NO-CHECK]
set &quot;run_nocheck=&quot;
if /i &quot;%~1&quot; == &quot;/NO-CHECK&quot; (
	set &quot;run_nocheck=1&quot;
	shift
)

:: command
set &quot;run_command=%~1&quot;
shift

if not defined run_command (
	&gt;&amp;2 echo:Command not specified
	goto :run_help
)

if defined run_nocheck (
	set &quot;run_progpath=%run_command%&quot;
	goto :run_install_args
)

set &quot;run_progpath=&quot;
for /f &quot;tokens=*&quot; %%c in ( &quot;%run_command%&quot; ) do (
	if not &quot;%%~$PATH:c&quot; == &quot;&quot; set &quot;run_progpath=%%~$PATH:c&quot;
	if exist &quot;%%~fc&quot; set &quot;run_progpath=%%~fc&quot;
)

if not defined run_progpath (
	&gt;&amp;2 echo:Command not found: %run_command%
	goto :run_help
)

:run_install_args

:: [arguments] or &quot;%V&quot;
set &quot;run_arguments=&quot;

:run_install_args_begin
if &quot;%~1&quot; == &quot;&quot; goto :run_install_args_end
	set &quot;run_arguments=%run_arguments% %1&quot;
	shift
goto :run_install_args_begin
:run_install_args_end

:: http://superuser.com/a/473602
:: http://www.robvanderwoude.com/ntstart.php
:: http://msdn.microsoft.com/en-us/library/windows/desktop/cc144101%28v=vs.85%29.aspx
if not defined run_arguments set &quot;run_arguments= &quot;%%V&quot;&quot;

:: Escape quotes before enclosing within quotes
set &quot;run_arguments=%run_arguments:&quot;=\&quot;%&quot;

for %%s in ( %run_subkey_list% ) do (
	reg add &quot;%run_classkey%\%%s\shell\%run_menu%\command&quot; /ve /d &quot;\&quot;%run_progpath%\&quot;%run_arguments%&quot; /f
)

if defined run_iconfile for %%s in ( %run_subkey_list% ) do (
	reg add &quot;%run_classkey%\%%s\shell\%run_menu%&quot; /v Icon /t REG_SZ /d &quot;%run_iconfile%&quot; /f
)
goto :EOF


:run_uninstall
if /i &quot;%run_menu%&quot; == &quot;cmd&quot; goto :run_forbidden

for %%s in ( %run_subkey_list% ) do (
	reg delete &quot;%run_classkey%\%%s\shell\%run_menu%&quot; /f
)
goto :EOF


:run_show
for %%s in ( %run_subkey_list% ) do (
	reg query &quot;%run_classkey%\%%s\shell\%run_menu%&quot; /s
)
goto :EOF


:run_forbidden
&gt;&amp;2 echo:the operation over this element is forbidden.
goto :EOF


:run_help
echo:Open the command identified by the menu over the folder. 
echo:
echo:%~n0 [/A] /I &quot;menu&quot; [/K iconfile] [/NO-CHECK] command [arguments]
echo:%~n0 [/A] /U &quot;menu&quot;
echo:%~n0 [/A] /S &quot;menu&quot;
echo:
echo:menu       The menu item of the Windows Explorer context menu.
echo:command    The command to be executed on selecting the menu.
echo:arguments  Arguments to be passed to the command (otherwise %%V).
echo:/A         Apply for all users. By default, for the current user only.
echo:/I         Install the menu item.
echo:/U         Uninstall the existing item. 
echo:/S         Show the Registry entries if they exist.
echo:/K icon    Set the menu icon.
echo:/NO-CHECK  Do not check the path to the command when installing.
goto :EOF


</code></pre></div></div></div>]]></description>
			<author><![CDATA[null@example.com (Rumata)]]></author>
			<pubDate>Fri, 07 Aug 2020 08:09:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=141523#p141523</guid>
		</item>
	</channel>
</rss>
