I can do it with powershell in this way (modifying the byte at pos 22):
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function SetAsAdministrator ($p_LinkFile) {
$tempFileName = [IO.Path]::GetRandomFileName()
$tempFile = [IO.FileInfo][IO.Path]::Combine($p_LinkFile.Directory, $tempFileName)
$writer = new-object System.IO.FileStream $tempFile, ([System.IO.FileMode]::Create)
$reader = $LinkFile.OpenRead()
while ($reader.Position -lt $reader.Length)
{
$byte = $reader.ReadByte()
if ($reader.Position -eq 22) {
$byte = 34
}
$writer.WriteByte($byte)
}
$reader.Close()
$writer.Close()
$LinkFile.Delete()
Rename-Item -Path $tempFile -NewName $p_LinkFile.Name
}
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;What I Want is to do the same with Autohotkey but i has no success using something like this:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FileCreateShortcut, Notepad.exe, %A_Desktop%\My Shortcut1.lnk, C:\, "%A_ScriptFullPath%", My Description, C:\My Icon.ico, i
MyFile1 = %A_Desktop%\My Shortcut1.lnk
FileHnd1 := FileOpen(MyFile1, "rw")
if !IsObject(FileHnd1)
{
MsgBox Can't open "%MyFile1%" for writing.
return
}
FileHnd1.Position(22)
MyVar := 34
FileHnd.RawWrite(MyVar,1)
FileHnd1.Close()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Regards.