Old Issue: I'm trying to write a script in cmd where PS script sets the system format date as current date.....
::::::::::Edit New Issue: I made a bit of advancement. Now that I've more on completely to PowerShell here is the code:
$a=get-date -UFormat "%s"
<# $env:ElDate = ''
Set-Item -Path Env:\ElDate -Value (get-date -UFormat "%s") #>
$HxVal= [System.Convert]::ToString($a,16) <# '{0:x}' -f $a #>
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name InstallDate -Value $HxVal
reg add 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion' /v InstallDate /d $HxVal /f
return $HxVal
But I'm getting this.
Set-ItemProperty: D:\Download\Scripts\test\GetCDate.ps1:5:1
Line |
5 | Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVe …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Requested registry access is not allowed.
ERROR: Access is denied.
6267ab4f
How do I write in LocalMachine? Can anyone Help?
Regards,
Thanks everyone! I found the solution. Its just that I was aiming so high that I didn't see besides me. A very simple "Back To School" solution did it.
Run PowerShell as Administrator and execute the ps1 script in it. Now I just have to find an app that'll create its exe in administrative privileges.
Regards,