.net – 我可以在PowerShell中执行此操作吗?阅读注册表,将二进
发布时间:2020-12-14 05:46:49 所属栏目:Windows 来源:网络整理
导读:这是C#代码.你能帮我把它翻译成power shell吗? private static void Main(string[] args){ byte[] buffer = (byte[]) Registry.LocalMachine.OpenSubKey(@"HARDWAREACPIDSDTHP____8510x 0010000").GetValue("00000000"); if (File.Exists("8510x.orig"
这是C#代码.你能帮我把它翻译成power
shell吗?
private static void Main(string[] args) { byte[] buffer = (byte[]) Registry.LocalMachine.OpenSubKey(@"HARDWAREACPIDSDTHP____8510x 0010000").GetValue("00000000"); if (File.Exists("8510x.orig")) { Console.WriteLine("File 8510x.orig already exists."); } else { using (FileStream stream = new FileStream("8510x.orig",FileMode.CreateNew)) { stream.Write(buffer,buffer.Length); stream.Flush(); stream.Close(); } Console.WriteLine("Wrote 8510x.orig."); } } 解决方法
您不想使用Out-File,因为它以字符串形式输出并使用unicode启动.以下工作基于类似的注册表项:
$b = Get-ItemProperty HKLM:HARDWAREACPIDSDTA7546A7546011 0000011 00000000 $b.'00000000' | Set-Content foo.txt -enc byte 请注意,当您希望更直接地控制写入文件的内容时,Set-Content非常有用,尤其是在您想要写入原始字节时. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 如果我使用LoadIconWithScaleDown创建它,是否需
- windows – 枚举特定组的所有用户的AD查询语法是什么?
- Windows 设置定时任务
- Windows Server 2012 R2仍然需要时间同步吗?
- windows-server-2008 – 在Windows Server 2008上移动和更改
- 如何在Windows上使用OpenSSH证书?
- .net – 什么是Microsoft.Contracts以及它来自哪里?
- 什么被认为是Windows服务器的“SSH”?
- 为Windows创建R包
- 是否可以在Windows主机上执行Vagrant Ansible配置程序?
推荐文章
站长推荐
热点阅读