如何在快捷方式名称已注册文本的地方编辑快捷方式属性® [英] How to edit shortcut properties where shortcut name has registered text ®

查看:89
本文介绍了如何在快捷方式名称已注册文本的地方编辑快捷方式属性®的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用批处理脚本来编辑快捷方式的属性.但是快捷方式名称包含一个字符®,因此当我运行changeproperties.bat文件时,它无法正确读取文件名.我可以通过poweshell执行相同的任务. 我的powershell脚本具有belwo行,并且可以运行

I am trying to edit the properties of the shortcut using batch script. But the short cut name includes a character ® hence when i run the changeproperties.bat file it fails to read the file name correctly. I am able to do the same task via poweshell. My powershell script has belwo line and it works

    $shortCut = ("$desktop\testapp®.lnk")
    $shell = New-Object -COM WScript.Shell
    $shortcut = $shell.CreateShortcut($shortCut)  ## Open the lnk
    $shortcut.TargetPath = "C:\Users\Public\newtarget.bat"
    $shortCut.Save()

我将在其中运行此程序的计算机没有运行powershell的权限.因此,尝试编写类似的bat文件.

The machine where i will run this will not have permission to run powershell. Hence trying to write similar bat file.

    echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
    echo sLinkFile = "%USERPROFILE%\Desktop\testapp®©.lnk" >> %SCRIPT%
    echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
    echo oLink.TargetPath = "C:\Users\Public\newtarget.bat" >> %SCRIPT%
    echo oLink.Save >> %SCRIPT%

但是这不起作用.当我运行它时,它会创建带有额外添加的特殊字符的快捷方式,例如此testapp©.

But this is not working. When i run it creates shortcut with extra added special character like this testapp©.

如何更正此问题.

推荐答案

您应首先使用Notepad++ANSI保存文件 然后执行此代码,它将为您工作.

You should first save your file with Notepad++ with ANSI Then execute this code and it will works for you.

@echo off
(   
    echo Set oWS = CreateObject("WScript.Shell"^)
    echo sLinkFile = "%USERPROFILE%\Desktop\testapp®.lnk"
    echo Set oLink = oWS.CreateShortcut(sLinkFile^)
    echo oLink.TargetPath = "C:\Users\Public\newtarget.bat"
    echo oLink.Save
)>%tmp%\%~n0.vbs
cscript /nologo %tmp%\%~n0.vbs

这篇关于如何在快捷方式名称已注册文本的地方编辑快捷方式属性®的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆