Windows 10中批处理文件中的%1无法恢复

AKA_Beest

我正在尝试为文件类型的安装程序创建批处理文件。问题是,每当我运行批处理文件时,%1就会消失并且不会应用于ftype。取而代之的是,只留下引号。这是代码。

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------    

assoc .beest=beestTest
ftype beestTest="C:\BeestFileType\TextEditor.exe" -f "%1" %*
pause

由于某些原因,这是不显示%1的输出。

.beest=beestTest
beestTest="C:\BeestFileType\TextEditor.exe" -f ""
Press any key to continue . . .
AKA_Beest

因此,我的解决方案是使用%% 1而不是%1,因为双精度百分比使它显示%而不是查找参数。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

批处理文件在Windows 10中无法正确运行

为什么我无法在Windows 10中运行的jenkins管道中运行批处理文件?

无法为包含 .py 文件的批处理文件进行任务调度以在 Windows 10 中启动

在python中为Maya(Windows 10)运行批处理文件时,无法识别Imagemagick

Windows 10中无法将'java'识别为内部或外部命令,可操作程序或批处理文件

如何在Windows 10中的批处理文件中从%〜dp0末尾删除空间

在Windows 10下批处理文件中获取目录或文件简称的问题

如何使用批处理文件在 Windows 10 中删除具有特定名称的文件?

批处理文件以在Windows中运行其他批处理文件

使用powershell编辑Windows批处理文件中的文件

批处理文件在Windows 10升级中不起作用

为什么Windows批处理文件中的换行符导致无法识别括号?

如何测试gcc是否无法在Windows批处理文件(cmd)中编译程序?

在Windows批处理文件中扩展变量

在Windows批处理文件中打开网页

在Windows Subsystem for Linux中执行批处理文件

批处理文件中的 Windows 上的诗歌

Windows批处理文件中的部分代码未执行

避免在Windows批处理文件中同时调用

问号获取URL编码在Windows批处理文件中

使用Ansible在Windows中运行批处理文件

Windows批处理文件中的git grep和xargs?

Windows批处理文件中的LF与CRLF行尾

Windows 批处理文件中的@CLS 有什么作用

在Windows批处理文件中的SET上使用变量

如何正确转义Windows批处理文件中的括号?

在 Windows 批处理文件中运行 sbt 命令

在MS-Windows中执行批处理文件

在Windows批处理文件中解析并传递特殊字符