Sign in to follow this  
Followers 0

Help Translating Powershell version Win10 login BG Tool to AutoIt

2 posts in this topic

I'm not familar with popweshell ,could someone help me translate the code below to autoit ? thanks in advance.

$priPath = $args[0]
$outputPath = $args[1]
$replacementPath = $args[2]
$ErrorActionPreference = "Stop"

$inputStream = [System.IO.File]::OpenRead($priPath)
$outputStream = [System.IO.File]::Create($outputPath)
$replacementStream = [System.IO.File]::OpenRead($replacementPath)

$inputReader = New-Object System.IO.BinaryReader -ArgumentList $inputStream
$outputWriter = New-Object System.IO.BinaryWriter -ArgumentList $outputStream

$replacementLengthAligned = ([Math]::Ceiling($replacementStream.Length / 8) * 8)

# header
$inputStream.Seek(0x14, "Begin") | Out-Null
$headerLength = $inputReader.ReadUInt32()
$inputStream.Seek(0xB8, "Begin") | Out-Null
$dataitemOffset = $inputReader.ReadUInt32()
$origDataitemLength = $inputReader.ReadUInt32()
$dataitemLength = $origDataitemLength + $replacementLengthAligned
$outputStream.Seek(0xBC, "Begin") | Out-Null

# dataitem
$outputStream.Seek($headerLength + $dataitemOffset + 0x18, "Begin") | Out-Null
$inputStream.Seek($headerLength + $dataitemOffset + 0x24, "Begin") | Out-Null
$stringCount = $inputReader.ReadUInt16()
$blobCount = $inputReader.ReadUInt16()
$origDataLength = $inputReader.ReadUInt32()
$outputStream.Seek(0xC, "Current") | Out-Null
$outputWriter.Write([int]($origDataLength + $replacementLengthAligned))
$outputStream.Seek($stringCount * 4, "Current") | Out-Null
for ($i = 0; $i -lt 10; $i++)
$outputStream.Seek(($blobCount - 10) * 8, "Current") | Out-Null

# data
$outputStream.Seek($origDataLength, "Current") | Out-Null
if ($outputStream.Length - $outputStream.Position -ne 0x18)
    Write-Error "Not compatible with this PRI file."

# footer
$outputStream.Seek($replacementLengthAligned - $replacementStream.Length, "Current") | Out-Null

$outputStream.Seek(0xC, "Begin") | Out-Null
$outputStream.Seek(-0xC, "End") | Out-Null




Share this post

Link to post
Share on other sites


Perhaps you could describe what you want to achieve?

Requests like "who could pls. help to translate <other-lang-code> to autoit?" without a single line of self written autoit code aren't served here on a quite regular basis.


Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • ur
      By ur
      I am maintaining all the reusable code in a separate file as library.au3.
      In that file I have referenced some dependent files using fileinstall, so that they will be extracted when necessary.
      Problem is, if I use a function in the library.au3 in another script which doesn't require this dependent file, as I am including the whole file using include tag, it is embedding that file also.
      Is there any way to exclude that.
    • david1337
      By david1337
      Hi guys,
      I need a little help here
      I have this simple Powershell script, that is able to set "sig.htm" as signature in OWA for the mail account specified.
      First part of the script just loads the Exchange snapin, since this is needed for the Get-Mailbox command.
      #Add Exchange 2010/2013 snapin if not already loaded in the PowerShell session if (!(Get-PSSnapin | where {$_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010"})) { try { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction STOP } catch { #Snapin was not loaded Write-Warning $_.Exception.Message EXIT } . $env:ExchangeInstallPath\bin\RemoteExchange.ps1 Connect-ExchangeServer -auto -AllowClobber } $mailboxes = Get-Mailbox -Identity $mailboxes| foreach {$file= "sig.htm"; Set-MailboxMessageConfiguration -identity $_.alias -SignatureHtml "$(Get-Content -Path $file -ReadCount 0)"} What I want is for AutoIt to use Powershell.exe to run the script somehow. This way I would be able to use AutoIt variables and arrays together with the PS script.
       I guess the solution would be to run Powershell.exe with command line arguments?
      If that is not possible, maybe have the script stored as a "ps1" file, and interact with it that way? (not preferred)
    • tcox8
      By tcox8
      Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
    • WoodGrain
      By WoodGrain
      Hi guys,
      This is probably an obvious one, but I really don't use this command at all so am hoping you can spot my mistake.
      I'm running a powershell script on a schedule with the following script in a function, the function is being called in a loop, but the console process is not closing in the background and I end up with a bunch of console windows running in the background:
      Run(@comspec & ' /k PowerShell.exe -STA -NonInteractive -ExecutionPolicy ByPass -Command "& ''Z:\Powershell\365\GetNextDetails.ps1'' "', "", @SW_HIDE) Thanks!
    • caramen
      By caramen
      !Arf it i used [Start new topic] when i was in GUI section and the post was moved without i even noticed it. Can an admin move that to general (SORRY)!
      Hello guys ME again and my ugly english xD.
      This is the only one powershell command i am not able to use becose i dont found a way to insert the USERNAME $Variable at the first line. i am not able to find a third way to QUOTE a variable when i use "*" for the AutoIt command and the '*' for the PS command but i need to QUOTE inside the '*'PS command my $Variable
      $iPid = run("powershell get-aduser -Filter {sn -eq 'USERNAME'} -Properties sAMAccountName,Title" , @WindowsDir , @SW_HIDE , 0x2) $AllInfo = "" While 1 $AllInfo &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd $AllInfo = stringsplit($AllInfo , @LF , 2) ;split result in all @LF but don't use the splitted result for anything _ArrayDisplay($AllInfo) This gonna be my last question becose i can do all the rest (i guess & wish ) alone