powershell - PowerShell Script Running Issues - Has to be ran twice in ISE and does not work when executed from file explorer location
问题描述
I'm currently experiencing some problems with importing/editing existing registry keys into a printer driver location.
After some searching I found that Set-ItemProperty
is the exact thing I need to rewrite subkey areas within the registry, however, I've had a lot of trouble running it.
When the code is put directly into the PowerShell console it works perfectly and updates the file in just the way I want it to.
When the code is open and ran in Powershell ISE it has to run several times consecutively (spammed around 3 times) for it works.
When the code is ran from its PS1 file from its file explorer location (C:\user\RW Sandbox\Documents\Printerscripts) then it doesn't work at all, regardless of whether or not I've spammed the run invocation.
This is the code I was using (although mine includes a lot more hex than this example):
Set-ItemProperty -Path "HKLM:\SOFTWARE\Xerox\PrinterDriver\V5.0\Xerox Global Print Driver PCL6\DeviceSettings" -Name "CachedXrxDeviceSettings" -Type "binary" -Value ([byte[]](0x10,0x00,0x00,0x00,0x01,0x00,0x07,0x20,0x2b,0x16,0x58,0x02,0x00,0x00,0x00,0x00,0x4d,0x53,0x43,0x46,0x00,0x00,0x00,0x00,0x70,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03))
Within the PowerShell, the execution policy is currently unrestricted as initially, I believed that this might have been a permission issue.
解决方案
推荐阅读
- php - Mysql数据加密
- swift - 快速创建通用变量字典
- python - 调度python脚本时出错:fcron [12036]:无法执行'/usr/bin/sendmail':没有这样的文件或目录
- windows - 在适用于 Windows 的 Ubuntu 应用程序上安装 Docker
- sparql - 如何在sparql中找到一个国家的所有属性?
- lua - "bios.lua:26: [string "turbinecontrol"]:15: 'then' expected" 我不知道为什么会这样
- javascript - 将 Fluture 与 AWS 服务结合使用
- powershell - 使用 Invoke-Command 时要求用户输入
- c++11 - 设置提升优先级队列的最大大小
- security - oauth 2.0 有什么问题以及 open id connect 如何修复它?