bat中的PowerShell(多行代码作为一行)
一行中有一个工作批处理文件,其中包含PowerShell代码:bat中的PowerShell(多行代码作为一行),powershell,batch-file,Powershell,Batch File,一行中有一个工作批处理文件,其中包含PowerShell代码: powershell -Command "& {$cont = wget http://САЙТ.info/; $cont = $cont.Content; $FilePath = 'contentFronHtml.txt' -f $env:SystemDrive; $cont | Out-File -FilePath $FilePath -Append -Width 200;}" 我想破解PowerShell代码以获得类
powershell -Command "& {$cont = wget http://САЙТ.info/; $cont = $cont.Content; $FilePath = 'contentFronHtml.txt' -f $env:SystemDrive; $cont | Out-File -FilePath $FilePath -Append -Width 200;}"
我想破解PowerShell代码以获得类似以下内容:
SET LONG_COMMAND="$cont = wget http://САЙТ.info/;"
"$cont = $cont.Content;"
"$FilePath = 'contentFronHtml.txt' -f $env:SystemDrive;$cont | Out-File -
FilePath; $FilePath -Append -Width 200;"
powershell -Command "& {LONG_COMMAND}"
如何连接PowerShell代码字符串?我会将您的PowerShell代码保存为.ps1文件,然后从命令行运行它:
powershell -File "C:\folder\test.ps1"
然后,要在多行上分解长命令,请按照以下步骤进行操作:
这意味着您要将PowerShell代码与批处理代码分离,并且批处理文件中不再包含难以读取的内嵌PowerShell代码。我会将PowerShell代码保存为.ps1文件,然后从命令行运行它:
powershell -File "C:\folder\test.ps1"
然后,要在多行上分解长命令,请按照以下步骤进行操作:
这意味着您要将PowerShell代码与批处理代码分离,并且批处理文件中不再包含难以读取的内嵌PowerShell代码。执行以下操作:
echo>%temp%\file.ps1 SET LONG_COMMAND="$cont = wget http://САЙТ.info/;"
echo>>%temp%\file.ps1 "$cont = $cont.Content;"
echo>>%temp%\file.ps1 "$FilePath = 'contentFronHtml.txt' -f
echo>>%temp%\file.ps1 $env:SystemDrive;$cont ^| Out-File -
echo>>%temp%\file.ps1 FilePath; $FilePath -Append -Width 200;"
echo>>%temp%\file.ps1 powershell -Command "& {LONG_COMMAND}"
powershell %temp%\file.ps1
这样做:
echo>%temp%\file.ps1 SET LONG_COMMAND="$cont = wget http://САЙТ.info/;"
echo>>%temp%\file.ps1 "$cont = $cont.Content;"
echo>>%temp%\file.ps1 "$FilePath = 'contentFronHtml.txt' -f
echo>>%temp%\file.ps1 $env:SystemDrive;$cont ^| Out-File -
echo>>%temp%\file.ps1 FilePath; $FilePath -Append -Width 200;"
echo>>%temp%\file.ps1 powershell -Command "& {LONG_COMMAND}"
powershell %temp%\file.ps1
我希望这样做:
PowerShell -Command "first line up to the end of a command;"^
"next line up to the end of a command;"^
"another line up to the end of a command;"^
"last line"
你也可以试试这个主意:
Set "MyCmnd=first line up to the end of a command;"
Set "MyCmnd=%MyCmnd% next line up to the end of a command;"
Set "MyCmnd=%MyCmnd% another line up to the end of a command;"
Set "MyCmnd=%MyCmnd% last line"
Echo %MyCmnd%
我希望这样做:
PowerShell -Command "first line up to the end of a command;"^
"next line up to the end of a command;"^
"another line up to the end of a command;"^
"last line"
你也可以试试这个主意:
Set "MyCmnd=first line up to the end of a command;"
Set "MyCmnd=%MyCmnd% next line up to the end of a command;"
Set "MyCmnd=%MyCmnd% another line up to the end of a command;"
Set "MyCmnd=%MyCmnd% last line"
Echo %MyCmnd%
字符串连接是使用+完成的,对于转义序列,您需要使用baktick。您可以将脚本编码为base64,因为powershell可以从命令提示符运行base64编码的脚本。我尝试过,但它不起作用。您可以使用一个具体的示例Base64编码您的脚本!这是一个可怕的想法,例如,它将
powershell-Command'echo“Hello World”
更改为powershell.exe-encodedCommand和zqbjagabwagaciasablagwababvabvavwahiabakacia
——这完全是人类无法读取的!请参阅:字符串连接是使用+完成的,对于转义序列,您需要使用baktick。您可以将脚本编码为base64,因为powershell可以从命令提示符运行base64编码的脚本。我尝试过,但它不起作用。您可以使用一个具体的示例Base64编码您的脚本!这是一个可怕的想法,例如,它将powershell-Command'echo“Hello World”
更改为powershell.exe-encodedCommand和zqbjagabwagaciasablagwababvabvavwahiabakacia
——这完全是人类无法读取的!见: