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()
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%
But this is not working. When i run it creates shortcut with extra added special character like this testapp©.
How to correct this.
Using a Batch + VBScript hybrid solution would let you circumvent any Batch codepage issues, as well as removing the need to echo your VBScript code to a secondary script.
You should first save your file with
Notepad++
withANSI
Then execute this code and it will works for you.