0

My company needs to change the windows key on a bunch of machines and I'd like to include all the steps in a script.

To change the key while the user is still logged in (they don't have admin rights), I need to run cmd as admin and then run two commands within that command prompt to change the key.

So basically this:

  1. Run cmd as admin -u administrator -p passwordhere
  2. In that cmd line, run slmgr.vbs -ipk 00000-00000-00000-00000-00000 //new key goes here
  3. In that cmd line, run slmgr.vbs -ato // this activates windows once the new key gets entered
TylerH
  • 20,799
  • 66
  • 75
  • 101

3 Answers3

1

To start cmd as administrator, you can try "RUNAS" http://technet.microsoft.com/en-us/library/bb490994.aspx

Tom
  • 11
  • 2
0

Should be able to do it with powershell. Here

Run powershell from a batch to set execution policy to unrestricted

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList 'Set-ExecutionPolicy Restricted -Force' -Verb RunAs}"
Community
  • 1
  • 1
user3795654
  • 86
  • 3
  • 12
0

You really have a couple of issues. How do you get a script to run on each machine -- are you running a login script? OK, but login scripts do not run with admin rights. So you really need to address 2 issues, how do I get the script to run automatcially and how do I get it to run as admin without UAC prompt.

You could also simply update each machine using the remote registry feature of windows, but this is still hit and miss and not all machines would necessarily be available at the time you ran such a script.

What you really should consider is using a Group Policy to set the regsitry entries you need. There are articles on group policy editor, etc. all over the internet. But this article is specially about registry maintenance.

Gary Walker
  • 8,831
  • 3
  • 19
  • 41