将批处理添加到右键菜单

2025-03-04 19:40:59
推荐回答(2个)
回答1:

[HKEY_CLASSES_ROOT\*\shell\runas]
@="在右键显示的文字"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c C:\批处理.bat %1"

把上面的代码合适的更改后保存为一个reg文件

然后把下面的代码保存到 C:\批处理.bat

@echo off
set file=%1
if "%file%"=="" exit /b
for %%i in (%file%) do if "%%~si"=="" exit /b
for %%i in (%file%) do set name=%%~nxi&set path=%%~dpi
echo 文件或文件夹名称%name%.文件地址%path%.
pause

最后再解释一下C:\批处理.bat是为了方便取得名。可以任意更改。

推荐给那个批处理文件添加一个系统的属性

attrib +s C:\批处理.bat

回答2:

下一步操作什么

VBS右键菜单中添加CMD HERE

Set WshShell=CreateObject("Wscript.Shell")
WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmd here\",""
WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmd here\command\",""
WshShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CLASSES\Folder\shell\cmd here\command\","c:\你的批处理.bat %1","REG_SZ"
wscript.echo "操作成功"
set WshShell=nothing