Running PowerShell Commands in a Batch File

Open PowerShell and define the variable $code by putting your code in between the curly brackets.

$code = {
$IEComObject = New-Object -com “InternetExplorer.Application”; $IEComObject.visible = $True; $IEComObject.navigate(“https://www.youtube.com/watch?v=Wch3gJG2GJ4”)
}

Then encode into base64 using this command

[convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($code))

Then place the base64 sting in your batch file

powershell.exe -EncodedCommand CgAkAEkARQBDAG8AbQBPAGIAagBlAGMAdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAALQBjAG8AbQAgACIASQBuAHQAZQByAG4AZQB0AEUAeABwAGwAbwByAGUAcgAuAEEAcABwAGwAaQBjAGEAdABpAG8AbgAiADsAIAAkAEkARQBDAG8AbQBPAGIAagBlAGMAdAAuAHYAaQBzAGkAYgBsAGUAIAA9ACAAJABUAHIAdQBlADsAIAAkAEkARQBDAG8AbQBPAGIAagBlAGMAdAAuAG4AYQB2AGkAZwBhAHQAZQAoACIAaAB0AHQAcABzADoALwAvAHcAdwB3AC4AeQBvAHUAdAB1AGIAZQAuAGMAbwBtAC8AdwBhAHQAYwBoAD8AdgA9AFcAYwBoADMAZwBKAEcAMgBHAEoANAAiACkACgA=

Posted in Computers and OSs.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *