-
Notifications
You must be signed in to change notification settings - Fork 0
/
slmgr.vbs
3407 lines (2655 loc) · 140 KB
/
slmgr.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Windows Software Licensing Management Tool.
'
' Script Name: slmgr.vbs
'
Option Explicit
Dim g_objWMIService, g_strComputer, g_strUserName, g_strPassword, g_IsRemoteComputer
g_strComputer = "."
g_IsRemoteComputer = False
dim g_EchoString
g_EchoString = ""
dim g_objRegistry
Dim g_resourceDictionary, g_resourcesLoaded
Set g_resourceDictionary = CreateObject("Scripting.Dictionary")
g_resourcesLoaded = False
Dim g_DeterminedDisplayFlags
g_DeterminedDisplayFlags = False
Dim g_ShowKmsInfo
Dim g_ShowKmsClientInfo
Dim g_ShowTkaClientInfo
Dim g_ShowTBLInfo
Dim g_ShowPhoneInfo
g_ShowKmsInfo = False
g_ShowKmsClientInfo = false
g_ShowTBLInfo = False
g_ShowPhoneInfo = False
' Messages
'Global options
private const L_optInstallProductKey = "ipk"
private const L_optInstallProductKeyUsage = "Install product key (replaces existing key)"
private const L_optUninstallProductKey = "upk"
private const L_optUninstallProductKeyUsage = "Uninstall product key"
private const L_optActivateProduct = "ato"
private const L_optActivateProductUsage = "Activate Windows"
private const L_optDisplayInformation = "dli"
private const L_optDisplayInformationUsage = "Display license information (default: current license)"
private const L_optDisplayInformationVerbose = "dlv"
private const L_optDisplayInformationUsageVerbose = "Display detailed license information (default: current license)"
private const L_optExpirationDatime = "xpr"
private const L_optExpirationDatimeUsage = "Expiration date for current license state"
'Advanced options
private const L_optClearPKeyFromRegistry = "cpky"
private const L_optClearPKeyFromRegistryUsage = "Clear product key from the registry (prevents disclosure attacks)"
private const L_optInstallLicense = "ilc"
private const L_optInstallLicenseUsage = "Install license"
private const L_optReinstallLicenses = "rilc"
private const L_optReinstallLicensesUsage = "Re-install system license files"
private const L_optDisplayIID = "dti"
private const L_optDisplayIIDUsage = "Display Installation ID for offline activation"
private const L_optPhoneActivateProduct = "atp"
private const L_optPhoneActivateProductUsage = "Activate product with user-provided Confirmation ID"
private const L_optReArmWindows = "rearm"
private const L_optReArmWindowsUsage = "Reset the licensing status of the machine"
private const L_optReArmApplication = "rearm-app"
private const L_optReArmApplicationUsage = "Reset the licensing status of the given app"
private const L_optReArmSku = "rearm-sku"
private const L_optReArmSkuUsage = "Reset the licensing status of the given sku"
'KMS options
private const L_optSetKmsName = "skms"
private const L_optSetKmsNameUsage = "Set the name and/or the port for the KMS computer this machine will use. IPv6 address must be specified in the format [hostname]:port"
private const L_optClearKmsName = "ckms"
private const L_optClearKmsNameUsage = "Clear name of KMS computer used (sets the port to the default)"
private const L_optSetKmsLookupDomain = "skms-domain"
private const L_optSetKmsLookupDomainUsage = "Set the specific DNS domain in which all KMS SRV records can be found. This setting has no effect if the specific single KMS host is set via /skms option."
private const L_optClearKmsLookupDomain = "ckms-domain"
private const L_optClearKmsLookupDomainUsage = "Clear the specific DNS domain in which all KMS SRV records can be found. The specific KMS host will be used if set via /skms. Otherwise default KMS auto-discovery will be used."
private const L_optSetKmsHostCaching = "skhc"
private const L_optSetKmsHostCachingUsage = "Enable KMS host caching"
private const L_optClearKmsHostCaching = "ckhc"
private const L_optClearKmsHostCachingUsage = "Disable KMS host caching"
private const L_optSetActivationInterval = "sai"
private const L_optSetActivationIntervalUsage = "Set interval (minutes) for unactivated clients to attempt KMS connection. The activation interval must be between 15 minutes (min) and 30 days (max) although the default (2 hours) is recommended."
private const L_optSetRenewalInterval = "sri"
private const L_optSetRenewalIntervalUsage = "Set renewal interval (minutes) for activated clients to attempt KMS connection. The renewal interval must be between 15 minutes (min) and 30 days (max) although the default (7 days) is recommended."
private const L_optSetKmsListenPort = "sprt"
private const L_optSetKmsListenPortUsage = "Set TCP port KMS will use to communicate with clients"
private const L_optSetDNS = "sdns"
private const L_optSetDNSUsage = "Enable DNS publishing by KMS (default)"
private const L_optClearDNS = "cdns"
private const L_optClearDNSUsage = "Disable DNS publishing by KMS"
private const L_optSetNormalPriority = "spri"
private const L_optSetNormalPriorityUsage = "Set KMS priority to normal (default)"
private const L_optClearNormalPriority = "cpri"
private const L_optClearNormalPriorityUsage = "Set KMS priority to low"
private const L_optSetVLActivationType = "act-type"
private const L_optSetVLActivationTypeUsage = "Set activation type to 1 (for AD) or 2 (for KMS) or 3 (for Token) or 0 (for all)."
' Token-based Activation options
private const L_optListInstalledILs = "lil"
private const L_optListInstalledILsUsage = "List installed Token-based Activation Issuance Licenses"
private const L_optRemoveInstalledIL = "ril"
private const L_optRemoveInstalledILUsage = "Remove installed Token-based Activation Issuance License"
private const L_optListTkaCerts = "ltc"
private const L_optListTkaCertsUsage = "List Token-based Activation Certificates"
private const L_optForceTkaActivation = "fta"
private const L_optForceTkaActivationUsage = "Force Token-based Activation"
' Active Directory Activation options
private const L_optADActivate = "ad-activation-online"
private const L_optADActivateUsage = "Activate AD (Active Directory) forest with user-provided product key"
private const L_optADGetIID = "ad-activation-get-iid"
private const L_optADGetIIDUsage = "Display Installation ID for AD (Active Directory) forest"
private const L_optADApplyCID = "ad-activation-apply-cid"
private const L_optADApplyCIDUsage = "Activate AD (Active Directory) forest with user-provided product key and Confirmation ID"
private const L_optADListAOs = "ao-list"
private const L_optADListAOsUsage = "Display Activation Objects in AD (Active Directory)"
private const L_optADDeleteAO = "del-ao"
private const L_optADDeleteAOsUsage = "Delete Activation Objects in AD (Active Directory) for user-provided Activation Object"
' Option parameters
private const L_ParamsActivationID = "<Activation ID>"
private const L_ParamsActivationIDOptional = "[Activation ID]"
private const L_ParamsActIDOptional = "[Activation ID | All]"
private const L_ParamsApplicationID = "<Application ID>"
private const L_ParamsProductKey = "<Product Key>"
private const L_ParamsLicenseFile = "<License file>"
private const L_ParamsPhoneActivate = "<Confirmation ID>"
private const L_ParamsSetKms = "<Name[:Port] | : port>"
private const L_ParamsSetKmsLookupDomain = "<FQDN>"
private const L_ParamsSetListenKmsPort = "<Port>"
private const L_ParamsSetActivationInterval = "<Activation Interval>"
private const L_ParamsSetRenewalInterval = "<Renewal Interval>"
private const L_ParamsVLActivationTypeOptional = "[Activation-Type]"
private const L_ParamsRemoveInstalledIL = "<ILID> <ILvID>"
private const L_ParamsForceTkaActivation = "<Certificate Thumbprint> [<PIN>]"
private const L_ParamsAONameOptional = "[Activation Object name]"
private const L_ParamsAODistinguishedName = "<Activation Object DN | Activation Object RDN>"
' Miscellaneous messages
private const L_MsgHelp_1 = "Windows Software Licensing Management Tool"
private const L_MsgHelp_2 = "Usage: slmgr.vbs [MachineName [User Password]] [<Option>]"
private const L_MsgHelp_3 = "MachineName: Name of remote machine (default is local machine)"
private const L_MsgHelp_4 = "User: Account with required privilege on remote machine"
private const L_MsgHelp_5 = "Password: password for the previous account"
private const L_MsgGlobalOptions = "Global Options:"
private const L_MsgAdvancedOptions = "Advanced Options:"
private const L_MsgKmsClientOptions = "Volume Licensing: Key Management Service (KMS) Client Options:"
private const L_MsgKmsOptions = "Volume Licensing: Key Management Service (KMS) Options:"
private const L_MsgADOptions = "Volume Licensing: Active Directory (AD) Activation Options:"
private const L_MsgTkaClientOptions = "Volume Licensing: Token-based Activation Options:"
private const L_MsgInvalidOptions = "Invalid combination of command parameters."
private const L_MsgUnrecognizedOption = "Unrecognized option: "
private const L_MsgErrorProductNotFound = "Error: product not found."
private const L_MsgClearedPKey = "Product key from registry cleared successfully."
private const L_MsgInstalledPKey = "Installed product key %PKEY% successfully."
private const L_MsgUninstalledPKey = "Uninstalled product key successfully."
private const L_MsgErrorPKey = "Error: product key not found."
private const L_MsgInstallationID = "Installation ID: "
private const L_MsgPhoneNumbers = "Product activation telephone numbers can be obtained by searching the phone.inf file for the appropriate phone number for your location/country. You can open the phone.inf file from a Command Prompt or the Start Menu by running: notepad %systemroot%\system32\sppui\phone.inf"
private const L_MsgActivating = "Activating %PRODUCTNAME% (%PRODUCTID%) ..."
private const L_MsgActivated = "Product activated successfully."
private const L_MsgActivated_Failed = "Error: Product activation failed."
private const L_MsgConfID = "Confirmation ID for product %ACTID% deposited successfully."
private const L_MsgErrorLocalWMI = "Error 0x%ERRCODE% occurred in connecting to the local WMI provider."
private const L_MsgErrorLocalRegistry = "Error 0x%ERRCODE% occurred in connecting to the local registry."
private const L_MsgErrorConnection = "Error 0x%ERRCODE% occurred in connecting to server %COMPUTERNAME%."
private const L_MsgInfoRemoteConnection = "Connected to server %COMPUTERNAME%."
private const L_MsgErrorConnectionRegistry = "Error 0x%ERRCODE% occurred in connecting to the registry on server %COMPUTERNAME%."
private const L_MsgErrorImpersonation = "Error 0x%ERRCODE% occurred in setting impersonation level."
private const L_MsgErrorAuthenticationLevel = "Error 0x%ERRCODE% occurred in setting authentication level."
private const L_MsgErrorWMI = "Error 0x%ERRCODE% occurred in creating a locator object."
private const L_MsgErrorText_6 = "On a computer running Microsoft Windows non-core edition, run 'slui.exe 0x2a 0x%ERRCODE%' to display the error text."
private const L_MsgErrorText_8 = "Error: "
private const L_MsgErrorText_9 = "Error: option %OPTION% needs %PARAM%"
private const L_MsgErrorText_11 = "The machine is running within the non-genuine grace period. Run 'slui.exe' to go online and make the machine genuine."
private const L_MsgErrorText_12 = "Windows is running within the non-genuine notification period. Run 'slui.exe' to go online and validate Windows."
private const L_MsgLicenseFile = "License file %LICENSEFILE% installed successfully."
private const L_MsgKmsPriSetToLow = "KMS priority set to Low"
private const L_MsgKmsPriSetToNormal = "KMS priority set to Normal"
private const L_MsgWarningKmsPri = "Warning: Priority can only be set on a KMS machine that is also activated."
private const L_MsgKmsDnsPublishingDisabled = "DNS publishing disabled"
private const L_MsgKmsDnsPublishingEnabled = "DNS publishing enabled"
private const L_MsgKmsDnsPublishingWarning = "Warning: DNS Publishing can only be set on a KMS machine that is also activated."
private const L_MsgKmsPortSet = "KMS port set to %PORT% successfully."
private const L_MsgWarningKmsReboot = "Warning: a KMS reboot is needed for this setting to take effect."
private const L_MsgWarningKmsPort = "Warning: KMS port can only be set on a KMS machine that is also activated."
private const L_MsgRenewalSet = "Volume renewal interval set to %RENEWAL% minutes successfully."
private const L_MsgWarningRenewal = "Warning: Volume renewal interval can only be set on a KMS machine that is also activated."
private const L_MsgActivationSet = "Volume activation interval set to %ACTIVATION% minutes successfully."
private const L_MsgWarningActivation = "Warning: Volume activation interval can only be set on a KMS machine that is also activated."
private const L_MsgKmsNameSet = "Key Management Service machine name set to %KMS% successfully."
private const L_MsgKmsNameCleared = "Key Management Service machine name cleared successfully."
private const L_MsgKmsLookupDomainSet = "Key Management Service lookup domain set to %FQDN% successfully."
private const L_MsgKmsLookupDomainCleared = "Key Management Service lookup domain cleared successfully."
private const L_MsgKmsUseMachineNameOverrides = "Warning: /skms setting overrides the /skms-domain setting. %KMS% will be used for activation."
private const L_MsgKmsUseMachineName = "Warning: /skms setting is in effect. %KMS% will be used for activation."
private const L_MsgKmsUseLookupDomain = "Warning: /skms-domain setting is in effect. %FQDN% will be used for DNS SRV record lookup."
private const L_MsgKmsHostCachingDisabled = "KMS host caching is disabled"
private const L_MsgKmsHostCachingEnabled = "KMS host caching is enabled"
private const L_MsgErrorActivationID = "Error: Activation ID (%ActID%) not found."
private const L_MsgVLActivationTypeSet = "Volume activation type set successfully."
private const L_MsgRearm_1 = "Command completed successfully."
private const L_MsgRearm_2 = "Please restart the system for the changes to take effect."
private const L_MsgRemainingWindowsRearmCount = "Remaining Windows rearm count: %COUNT%"
private const L_MsgRemainingSkuRearmCount = "Remaining SKU rearm count: %COUNT%"
private const L_MsgRemainingAppRearmCount = "Remaining App rearm count: %COUNT%"
' Used for xpr
private const L_MsgLicenseStatusUnlicensed = "Unlicensed"
private const L_MsgLicenseStatusVL = "Volume activation will expire %ENDDATE%"
private const L_MsgLicenseStatusTBL = "Timebased activation will expire %ENDDATE%"
private const L_MsgLicenseStatusAVMA = "Automatic VM activation will expire %ENDDATE%"
private const L_MsgLicenseStatusLicensed = "The machine is permanently activated."
private const L_MsgLicenseStatusInitialGrace = "Initial grace period ends %ENDDATE%"
private const L_MsgLicenseStatusAdditionalGrace = "Additional grace period ends %ENDDATE%"
private const L_MsgLicenseStatusNonGenuineGrace = "Non-genuine grace period ends %ENDDATE%"
private const L_MsgLicenseStatusNotification = "Windows is in Notification mode"
private const L_MsgLicenseStatusExtendedGrace = "Extended grace period ends %ENDDATE%"
' Used for dli/dlv
private const L_MsgLicenseStatusUnlicensed_1 = "License Status: Unlicensed"
private const L_MsgLicenseStatusLicensed_1 = "License Status: Licensed"
private const L_MsgLicenseStatusVL_1 = "Volume activation expiration: %MINUTE% minute(s) (%DAY% day(s))"
private const L_MsgLicenseStatusTBL_1 = "Timebased activation expiration: %MINUTE% minute(s) (%DAY% day(s))"
private const L_MsgLicenseStatusAVMA_1 = "Automatic VM activation expiration: %MINUTE% minute(s) (%DAY% day(s))"
private const L_MsgLicenseStatusInitialGrace_1 = "License Status: Initial grace period"
private const L_MsgLicenseStatusAdditionalGrace_1 = "License Status: Additional grace period (KMS license expired or hardware out of tolerance)"
private const L_MsgLicenseStatusNonGenuineGrace_1 = "License Status: Non-genuine grace period."
private const L_MsgLicenseStatusNotification_1 = "License Status: Notification"
private const L_MsgLicenseStatusExtendedGrace_1 = "License Status: Extended grace period"
private const L_MsgNotificationErrorReasonNonGenuine = "Notification Reason: 0x%ERRCODE% (non-genuine)."
private const L_MsgNotificationErrorReasonExpiration = "Notification Reason: 0x%ERRCODE% (grace time expired)."
private const L_MsgNotificationErrorReasonOther = "Notification Reason: 0x%ERRCODE%."
private const L_MsgLicenseStatusTimeRemaining = "Time remaining: %MINUTE% minute(s) (%DAY% day(s))"
private const L_MsgLicenseStatusUnknown = "License Status: Unknown"
private const L_MsgLicenseStatusEvalEndData = "Evaluation End Date: "
private const L_MsgReinstallingLicenses = "Re-installing license files ..."
private const L_MsgLicensesReinstalled = "License files re-installed successfully."
private const L_MsgServiceVersion = "Software licensing service version: "
private const L_MsgProductName = "Name: "
private const L_MsgProductDesc = "Description: "
private const L_MsgActID = "Activation ID: "
private const L_MsgAppID = "Application ID: "
private const L_MsgPID4 = "Extended PID: "
private const L_MsgChannel = "Product Key Channel: "
private const L_MsgProcessorCertUrl = "Processor Certificate URL: "
private const L_MsgMachineCertUrl = "Machine Certificate URL: "
private const L_MsgUseLicenseCertUrl = "Use License URL: "
private const L_MsgPKeyCertUrl = "Product Key Certificate URL: "
private const L_MsgValidationUrl = "Validation URL: "
private const L_MsgPartialPKey = "Partial Product Key: "
private const L_MsgErrorLicenseNotInUse = "This license is not in use."
private const L_MsgKmsInfo = "Key Management Service client information"
private const L_MsgCmid = "Client Machine ID (CMID): "
private const L_MsgRegisteredKmsName = "Registered KMS machine name: "
private const L_MsgKmsLookupDomain = "Registered KMS SRV record lookup domain: "
private const L_MsgKmsFromDnsUnavailable = "DNS auto-discovery: KMS name not available"
private const L_MsgKmsFromDns = "KMS machine name from DNS: "
private const L_MsgKmsIpAddress = "KMS machine IP address: "
private const L_MsgKmsIpAddressUnavailable = "KMS machine IP address: not available"
private const L_MsgKmsPID4 = "KMS machine extended PID: "
private const L_MsgActivationInterval = "Activation interval: %INTERVAL% minutes"
private const L_MsgRenewalInterval = "Renewal interval: %INTERVAL% minutes"
private const L_MsgKmsEnabled = "Key Management Service is enabled on this machine"
private const L_MsgKmsCurrentCount = "Current count: "
private const L_MsgKmsListeningOnPort = "Listening on Port: "
private const L_MsgKmsPriNormal = "KMS priority: Normal"
private const L_MsgKmsPriLow = "KMS priority: Low"
private const L_MsgVLActivationTypeAll = "Configured Activation Type: All"
private const L_MsgVLActivationTypeAD = "Configured Activation Type: AD"
private const L_MsgVLActivationTypeKMS = "Configured Activation Type: KMS"
private const L_MsgVLActivationTypeToken = "Configured Activation Type: Token"
private const L_MsgVLMostRecentActivationInfo = "Most recent activation information:"
private const L_MsgInvalidDataError = "Error: The data is invalid"
private const L_MsgUndeterminedPrimaryKey = "Warning: SLMGR was not able to validate the current product key for Windows. Please upgrade to the latest service pack."
private const L_MsgUndeterminedPrimaryKeyOperation = "Warning: This operation may affect more than one target license. Please verify the results."
private const L_MsgUndeterminedOperationFormat = "Processing the license for %PRODUCTDESCRIPTION% (%PRODUCTID%)."
private const L_MsgPleaseActivateRefreshKMSInfo = "Please use slmgr.vbs /ato to activate and update KMS client information in order to update values."
private const L_MsgTokenBasedActivationMustBeDone = "This system is configured for Token-based activation only. Use slmgr.vbs /fta to initiate Token-based activation, or slmgr.vbs /act-type to change the activation type setting."
private const L_MsgKmsCumulativeRequestsFromClients = "Key Management Service cumulative requests received from clients"
private const L_MsgKmsTotalRequestsRecieved = "Total requests received: "
private const L_MsgKmsFailedRequestsReceived = "Failed requests received: "
private const L_MsgKmsRequestsWithStatusUnlicensed = "Requests with License Status Unlicensed: "
private const L_MsgKmsRequestsWithStatusLicensed = "Requests with License Status Licensed: "
private const L_MsgKmsRequestsWithStatusInitialGrace = "Requests with License Status Initial grace period: "
private const L_MsgKmsRequestsWithStatusLicenseExpiredOrHwidOot = "Requests with License Status License expired or Hardware out of tolerance: "
private const L_MsgKmsRequestsWithStatusNonGenuineGrace = "Requests with License Status Non-genuine grace period: "
private const L_MsgKmsRequestsWithStatusNotification = "Requests with License Status Notification: "
private const L_MsgRemoteWmiVersionMismatch = "The remote machine does not support this version of SLMgr.vbs"
private const L_MsgRemoteExecNotSupported = "This command of SLMgr.vbs is not supported for remote execution"
'
' Token-based Activation issuance licenses
'
private const L_MsgTkaLicenses = "Token-based Activation Issuance Licenses:"
private const L_MsgTkaLicenseHeader = "%ILID% %ILVID%"
private const L_MsgTkaLicenseILID = "License ID (ILID): %ILID%"
private const L_MsgTkaLicenseILVID = "Version ID (ILvID): %ILVID%"
private const L_MsgTkaLicenseExpiration = "Valid to: %TODATE%"
private const L_MsgTkaLicenseAdditionalInfo = "Additional Information: %MOREINFO%"
private const L_MsgTkaLicenseAuthZStatus = "Error: 0x%ERRCODE%"
private const L_MsgTkaLicenseDescr = "Description: %DESC%"
private const L_MsgTkaLicenseNone = "No licenses found."
private const L_MsgTkaRemoving = "Removing Token-based Activation License ..."
private const L_MsgTkaRemovedItem = "Removed license with SLID=%SLID%."
private const L_MsgTkaRemovedNone = "No licenses found."
private const L_MsgTkaInfoAdditionalInfo = "Additional Information: %MOREINFO%"
private const L_MsgTkaInfo = "Token-based Activation information"
private const L_MsgTkaInfoILID = "License ID (ILID): %ILID%"
private const L_MsgTkaInfoILVID = "Version ID (ILvID): %ILVID%"
private const L_MsgTkaInfoGrantNo = "Grant Number: %GRANTNO%"
private const L_MsgTkaInfoThumbprint = "Certificate Thumbprint: %THUMBPRINT%"
private const L_MsgTkaCertThumbprint = "Thumbprint: %THUMBPRINT%"
private const L_MsgTkaCertSubject = "Subject: %SUBJECT%"
private const L_MsgTkaCertIssuer = "Issuer: %ISSUER%"
private const L_MsgTkaCertValidFrom = "Valid from: %FROMDATE%"
private const L_MsgTkaCertValidTo = "Valid to: %TODATE%"
'
' AD Activation messages
'
private const L_MsgADInfo = "AD Activation client information"
private const L_MsgADInfoAOName = "Activation Object name: "
private const L_MsgADInfoAODN = "AO DN: "
private const L_MsgADInfoExtendedPid = "AO extended PID: "
private const L_MsgADInfoActID = "AO activation ID: "
private const L_MsgActObjAvailable = "Activation Objects"
private const L_MsgActObjNoneFound = "No objects found"
private const L_MsgSucess = "Operation completed successfully."
private const L_MsgADSchemaNotSupported = "Active Directory-Based Activation is not supported in the current Active Directory schema."
'
' Automatic VM Activation messages
'
private const L_MsgAVMAInfo = "Automatic VM Activation client information"
private const L_MsgAVMAID = "Guest IAID: "
private const L_MsgAVMAHostMachineName = "Host machine name: "
private const L_MsgAVMALastActTime = "Activation time: "
private const L_MsgAVMAHostPid2 = "Host Digital PID2: "
private const L_MsgNotAvailable = "Not Available"
private const L_MsgCurrentTrustedTime = "Trusted time: "
private const NoPrimaryKeyFound = "NoPrimaryKeyFound"
private const TblPrimaryKey = "TblPrimaryKey"
private const NotSpecialCasePrimaryKey = "NotSpecialCasePrimaryKey"
private const IndeterminatePrimaryKeyFound = "IndeterminatePrimaryKey"
private const L_MsgError_C004C001 = "The activation server determined the specified product key is invalid"
private const L_MsgError_C004C003 = "The activation server determined the specified product key is blocked"
private const L_MsgError_C004C017 = "The activation server determined the specified product key has been blocked for this geographic location."
private const L_MsgError_C004B100 = "The activation server determined that the computer could not be activated"
private const L_MsgError_C004C008 = "The activation server determined that the specified product key could not be used"
private const L_MsgError_C004C020 = "The activation server reported that the Multiple Activation Key has exceeded its limit"
private const L_MsgError_C004C021 = "The activation server reported that the Multiple Activation Key extension limit has been exceeded"
private const L_MsgError_C004D307 = "The maximum allowed number of re-arms has been exceeded. You must re-install the OS before trying to re-arm again"
private const L_MsgError_C004F009 = "The software Licensing Service reported that the grace period expired"
private const L_MsgError_C004F00F = "The Software Licensing Server reported that the hardware ID binding is beyond level of tolerance"
private const L_MsgError_C004F014 = "The Software Licensing Service reported that the product key is not available"
private const L_MsgError_C004F025 = "Access denied: the requested action requires elevated privileges"
private const L_MsgError_C004F02C = "The software Licensing Service reported that the format for the offline activation data is incorrect"
private const L_MsgError_C004F035 = "The software Licensing Service reported that the computer could not be activated with a Volume license product key. Volume licensed systems require upgrading from a qualified operating system. Please contact your system administrator or use a different type of key"
private const L_MsgError_C004F038 = "The software Licensing Service reported that the computer could not be activated. The count reported by your Key Management Service (KMS) is insufficient. Please contact your system administrator"
private const L_MsgError_C004F039 = "The software Licensing Service reported that the computer could not be activated. The Key Management Service (KMS) is not enabled"
private const L_MsgError_C004F041 = "The software Licensing Service determined that the Key Management Server (KMS) is not activated. KMS needs to be activated"
private const L_MsgError_C004F042 = "The software Licensing Service determined that the specified Key Management Service (KMS) cannot be used"
private const L_MsgError_C004F050 = "The Software Licensing Service reported that the product key is invalid"
private const L_MsgError_C004F051 = "The software Licensing Service reported that the product key is blocked"
private const L_MsgError_C004F064 = "The software Licensing Service reported that the non-Genuine grace period expired"
private const L_MsgError_C004F065 = "The software Licensing Service reported that the application is running within the valid non-genuine period"
private const L_MsgError_C004F066 = "The Software Licensing Service reported that the product SKU is not found"
private const L_MsgError_C004F06B = "The software Licensing Service determined that it is running in a virtual machine. The Key Management Service (KMS) is not supported in this mode"
private const L_MsgError_C004F074 = "The Software Licensing Service reported that the computer could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information."
private const L_MsgError_C004F075 = "The Software Licensing Service reported that the operation cannot be completed because the service is stopping"
private const L_MsgError_C004F304 = "The Software Licensing Service reported that required license could not be found."
private const L_MsgError_C004F305 = "The Software Licensing Service reported that there are no certificates found in the system that could activate the product."
private const L_MsgError_C004F30A = "The Software Licensing Service reported that the computer could not be activated. The certificate does not match the conditions in the license."
private const L_MsgError_C004F30D = "The Software Licensing Service reported that the computer could not be activated. The thumbprint is invalid."
private const L_MsgError_C004F30E = "The Software Licensing Service reported that the computer could not be activated. A certificate for the thumbprint could not be found."
private const L_MsgError_C004F30F = "The Software Licensing Service reported that the computer could not be activated. The certificate does not match the criteria specified in the issuance license."
private const L_MsgError_C004F310 = "The Software Licensing Service reported that the computer could not be activated. The certificate does not match the trust point identifier (TPID) specified in the issuance license."
private const L_MsgError_C004F311 = "The Software Licensing Service reported that the computer could not be activated. A soft token cannot be used for activation."
private const L_MsgError_C004F312 = "The Software Licensing Service reported that the computer could not be activated. The certificate cannot be used because its private key is exportable."
private const L_MsgError_5 = "Access denied: the requested action requires elevated privileges"
private const L_MsgError_80070005 = "Access denied: the requested action requires elevated privileges"
private const L_MsgError_80070057 = "The parameter is incorrect"
private const L_MsgError_8007232A = "DNS server failure"
private const L_MsgError_8007232B = "DNS name does not exist"
private const L_MsgError_800706BA = "The RPC server is unavailable"
private const L_MsgError_8007251D = "No records found for DNS query"
' Registry constants
private const HKEY_LOCAL_MACHINE = &H80000002
private const HKEY_NETWORK_SERVICE = &H80000003
private const DefaultPort = "1688"
private const intKnownOption = 0
private const intUnknownOption = 1
private const SLKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
private const SLKeyPath32 = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
private const NSKeyPath = "S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
private const HR_S_OK = 0
private const HR_ERROR_FILE_NOT_FOUND = &H80070002
private const HR_SL_E_GRACE_TIME_EXPIRED = &HC004F009
private const HR_SL_E_NOT_GENUINE = &HC004F200
private const HR_SL_E_PKEY_NOT_INSTALLED = &HC004F014
private const HR_INVALID_ARG = &H80070057
private const HR_ERROR_DS_NO_SUCH_OBJECT = &H80072030
' AD Activation constants
private const ADLdapProvider = "LDAP:"
private const ADLdapProviderPrefix = "LDAP://"
private const ADRootDSE = "rootDSE"
private const ADConfigurationNC = "configurationNamingContext"
private const ADActObjContainer = "CN=Activation Objects,CN=Microsoft SPP,CN=Services,"
private const ADActObjContainerClass = "msSPP-ActivationObjectsContainer"
private const ADActObjClass = "msSPP-ActivationObject"
private const ADActObjAttribSkuId = "msSPP-CSVLKSkuId"
private const ADActObjAttribPid = "msSPP-CSVLKPid"
private const ADActObjAttribPartialPkey = "msSPP-CSVLKPartialProductKey"
private const ADActObjDisplayName = "displayName"
private const ADActObjAttribDN = "distinguishedName"
private const ADS_READONLY_SERVER = 4
' WMI class names
private const ServiceClass = "SoftwareLicensingService"
private const ProductClass = "SoftwareLicensingProduct"
private const TkaLicenseClass = "SoftwareLicensingTokenActivationLicense"
private const WindowsAppId = "55c92734-d682-4d71-983e-d6ec3f16059f"
private const ProductIsPrimarySkuSelectClause = "ID, ApplicationId, PartialProductKey, LicenseIsAddon, Description, Name"
private const KMSClientLookupClause = "KeyManagementServiceMachine, KeyManagementServicePort, KeyManagementServiceLookupDomain"
private const PartialProductKeyNonNullWhereClause = "PartialProductKey <> null"
private const EmptyWhereClause = ""
private const wbemImpersonationLevelImpersonate = 3
private const wbemAuthenticationLevelPktPrivacy = 6
'Call ShowErrorTest
Call ExecCommandLine()
ExitScript 0
Private Sub DisplayUsage ()
LineOut GetResource("L_MsgHelp_1")
LineOut GetResource("L_MsgHelp_2")
LineOut " " & GetResource("L_MsgHelp_3")
LineOut " " & GetResource("L_MsgHelp_4")
LineOut " " & GetResource("L_MsgHelp_5")
LineOut ""
LineOut GetResource("L_MsgGlobalOptions")
OptLine GetResource("L_optInstallProductKey"), GetResource("L_ParamsProductKey"), GetResource("L_optInstallProductKeyUsage")
OptLine GetResource("L_optActivateProduct"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optActivateProductUsage")
OptLine GetResource("L_optDisplayInformation"), GetResource("L_ParamsActIDOptional"), GetResource("L_optDisplayInformationUsage")
OptLine GetResource("L_optDisplayInformationVerbose"), GetResource("L_ParamsActIDOptional"), GetResource("L_optDisplayInformationUsageVerbose")
OptLine GetResource("L_optExpirationDatime"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optExpirationDatimeUsage")
LineFlush ""
LineOut GetResource("L_MsgAdvancedOptions")
OptLine GetResource("L_optClearPKeyFromRegistry"), "", GetResource("L_optClearPKeyFromRegistryUsage")
OptLine GetResource("L_optInstallLicense"), GetResource("L_ParamsLicenseFile"), GetResource("L_optInstallLicenseUsage")
OptLine GetResource("L_optReinstallLicenses"), "", GetResource("L_optReinstallLicensesUsage")
OptLine GetResource("L_optReArmWindows"), "", GetResource("L_optReArmWindowsUsage")
OptLine GetResource("L_optReArmApplication"), GetResource("L_ParamsApplicationID"), GetResource("L_optReArmApplicationUsage")
OptLine GetResource("L_optReArmSku"), GetResource("L_ParamsActivationID"), GetResource("L_optReArmSkuUsage")
OptLine GetResource("L_optUninstallProductKey"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optUninstallProductKeyUsage")
LineOut ""
OptLine GetResource("L_optDisplayIID"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optDisplayIIDUsage")
OptLine2 GetResource("L_optPhoneActivateProduct"), GetResource("L_ParamsPhoneActivate"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optPhoneActivateProductUsage")
LineOut ""
LineOut GetResource("L_MsgKmsClientOptions")
OptLine2 GetResource("L_optSetKmsName"), GetResource("L_ParamsSetKms"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optSetKmsNameUsage")
OptLine GetResource("L_optClearKmsName"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optClearKmsNameUsage")
OptLine2 GetResource("L_optSetKmsLookupDomain"), GetResource("L_ParamsSetKmsLookupDomain"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optSetKmsLookupDomainUsage")
OptLine GetResource("L_optClearKmsLookupDomain"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optClearKmsLookupDomainUsage")
OptLine GetResource("L_optSetKmsHostCaching"), "", GetResource("L_optSetKmsHostCachingUsage")
OptLine GetResource("L_optClearKmsHostCaching"), "", GetResource("L_optClearKmsHostCachingUsage")
LineFlush ""
LineOut GetResource("L_MsgTkaClientOptions")
OptLine GetResource("L_optListInstalledILs"), "", GetResource("L_optListInstalledILsUsage")
OptLine GetResource("L_optRemoveInstalledIL"), GetResource("L_ParamsRemoveInstalledIL"), GetResource("L_optRemoveInstalledILUsage")
OptLine GetResource("L_optListTkaCerts"), "", GetResource("L_optListTkaCertsUsage")
OptLine GetResource("L_optForceTkaActivation"), GetResource("L_ParamsForceTkaActivation"), GetResource("L_optForceTkaActivationUsage")
LineFlush ""
LineOut GetResource("L_MsgKmsOptions")
OptLine GetResource("L_optSetKmsListenPort"), GetResource("L_ParamsSetListenKmsPort"), GetResource("L_optSetKmsListenPortUsage")
OptLine GetResource("L_optSetActivationInterval"), GetResource("L_ParamsSetActivationInterval"), GetResource("L_optSetActivationIntervalUsage")
OptLine GetResource("L_optSetRenewalInterval"), GetResource("L_ParamsSetRenewalInterval"), GetResource("L_optSetRenewalIntervalUsage")
OptLine GetResource("L_optSetDNS"), "", GetResource("L_optSetDNSUsage")
OptLine GetResource("L_optClearDNS"), "", GetResource("L_optClearDNSUsage")
OptLine GetResource("L_optSetNormalPriority"), "", GetResource("L_optSetNormalPriorityUsage")
OptLine GetResource("L_optClearNormalPriority"), "", GetResource("L_optClearNormalPriorityUsage")
OptLine2 GetResource("L_optSetVLActivationType"), GetResource("L_ParamsVLActivationTypeOptional"), GetResource("L_ParamsActivationIDOptional"), GetResource("L_optSetVLActivationTypeUsage")
LineFlush ""
LineOut GetResource("L_MsgADOptions")
OptLine2 GetResource("L_optADActivate"), GetResource("L_ParamsProductKey"), GetResource("L_ParamsAONameOptional"), GetResource("L_optADActivateUsage")
OptLine GetResource("L_optADGetIID"), GetResource("L_ParamsProductKey"), GetResource("L_optADGetIIDUsage")
OptLine3 GetResource("L_optADApplyCID"), GetResource("L_ParamsProductKey"), GetResource("L_ParamsPhoneActivate"), GetResource("L_ParamsAONameOptional"), GetResource("L_optADApplyCIDUsage")
OptLine GetResource("L_optADListAOs"), "", GetResource("L_optADListAOsUsage")
OptLine GetResource("L_optADDeleteAO"), GetResource("L_ParamsAODistinguishedName"), GetResource("L_optADDeleteAOsUsage")
ExitScript 1
End Sub
Private Sub OptLine(strOption, strParams, strUsage)
LineOut "/" & strOption & " " & strParams
LineOut " " & strUsage
End Sub
Private Sub OptLine2(strOption, strParam1, strParam2, strUsage)
LineOut "/" & strOption & " " & strParam1 & " " & strParam2
LineOut " " & strUsage
End Sub
Private Sub OptLine3(strOption, strParam1, strParam2, strParam3, strUsage)
LineOut "/" & strOption & " " & strParam1 & " " & strParam2 & " " & strParam3
LineOut " " & strUsage
End Sub
Private Sub ExecCommandLine
Dim intOption, indexOption
Dim strOption, chOpt
Dim remoteInfo(3)
'
' First three parameters before "/" or "-" may be remote connection info
'
remoteInfo(0) = "."
intOption = intUnknownOption
For indexOption = 0 To 3
If indexOption >= WScript.Arguments.Count Then
Exit For
End If
strOption = WScript.Arguments.Item(indexOption)
chOpt = Left(strOption, 1)
If chOpt = "/" Or chOpt = "-" Then
intOption = intKnownOption
Exit For
End If
remoteInfo(indexOption) = strOption
Next
'
' Connect to remote only if syntax is reasonably good
'
If intUnknownOption = intOption Or 2 = indexOption Then
g_strComputer = "."
intOption = intUnknownOption
Else
g_strComputer = remoteInfo(0)
g_strUserName = remoteInfo(1)
g_strPassword = remoteInfo(2)
End If
Call Connect()
If intUnknownOption = intOption Then
LineOut GetResource("L_MsgInvalidOptions")
LineOut ""
Call DisplayUsage()
End If
intOption = ParseCommandLine(indexOption)
If intUnknownOption = intOption Then
LineOut GetResource("L_MsgUnrecognizedOption") & WScript.Arguments.Item(indexOption)
LineOut ""
Call DisplayUsage()
End If
End Sub
Private Function ParseCommandLine(index)
Dim strOption, chOpt
ParseCommandLine = intKnownOption
strOption = LCase(WScript.Arguments.Item(index))
chOpt = Left(strOption, 1)
If (chOpt <> "-") And (chOpt <> "/") Then
ParseCommandLine = intUnknownOption
Exit Function
End If
strOption = Right(strOption, Len(strOption) - 1)
If strOption = GetResource("L_optInstallLicense") Then
If HandleOptionParam(index+1, True, GetResource("L_optInstallLicense"), GetResource("L_ParamsLicenseFile")) Then
InstallLicense WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optInstallProductKey") Then
If HandleOptionParam(index+1, True, GetResource("L_optInstallProductKey"), GetResource("L_ParamsProductKey")) Then
InstallProductKey WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optUninstallProductKey") Then
If HandleOptionParam(index+1, False, GetResource("L_optUninstallProductKey"), GetResource("L_ParamsActivationIDOptional")) Then
UninstallProductKey WScript.Arguments.Item(index+1)
Else
UninstallProductKey ""
End If
ElseIf strOption = GetResource("L_optDisplayIID") Then
If HandleOptionParam(index+1, False, GetResource("L_optDisplayIID"), GetResource("L_ParamsActivationIDOptional")) Then
DisplayIID WScript.Arguments.Item(index+1)
Else
DisplayIID ""
End If
ElseIf strOption = GetResource("L_optActivateProduct") Then
If HandleOptionParam(index+1, False, GetResource("L_optActivateProduct"), GetResource("L_ParamsActivationIDOptional")) Then
ActivateProduct WScript.Arguments.Item(index+1)
Else
ActivateProduct ""
End If
ElseIf strOption = GetResource("L_optPhoneActivateProduct") Then
If HandleOptionParam(index+1, True, GetResource("L_optPhoneActivateProduct"), GetResource("L_ParamsPhoneActivate")) Then
If HandleOptionParam(index+2, False, GetResource("L_optPhoneActivateProduct"), GetResource("L_ParamsActivationIDOptional")) Then
PhoneActivateProduct WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
Else
PhoneActivateProduct WScript.Arguments.Item(index+1), ""
End If
End If
ElseIf strOption = GetResource("L_optDisplayInformation") Then
If HandleOptionParam(index+1, False, GetResource("L_optDisplayInformation"), "") Then
DisplayAllInformation WScript.Arguments.Item(index+1), False
Else
DisplayAllInformation "", False
End If
ElseIf strOption = GetResource("L_optDisplayInformationVerbose") Then
If HandleOptionParam(index+1, False, GetResource("L_optDisplayInformationVerbose"), "") Then
DisplayAllInformation WScript.Arguments.Item(index+1), True
Else
DisplayAllInformation "", True
End If
ElseIf strOption = GetResource("L_optClearPKeyFromRegistry") Then
ClearPKeyFromRegistry
ElseIf strOption = GetResource("L_optReinstallLicenses") Then
ReinstallLicenses
ElseIf strOption = GetResource("L_optReArmWindows") Then
ReArmWindows()
ElseIf strOption = GetResource("L_optReArmApplication") Then
If HandleOptionParam(index+1, True, GetResource("L_optReArmApplication"), GetResource("L_ParamsApplicationID")) Then
ReArmApp WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optReArmSku") Then
If HandleOptionParam(index+1, True, GetResource("L_optReArmSku"), GetResource("L_ParamsActivationID")) Then
ReArmSku WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optExpirationDatime") Then
If HandleOptionParam(index+1, False, GetResource("L_optExpirationDatime"), GetResource("L_ParamsActivationIDOptional")) Then
ExpirationDatime WScript.Arguments.Item(index+1)
Else
ExpirationDatime ""
End If
ElseIf strOption = GetResource("L_optSetKmsName") Then
If HandleOptionParam(index+1, True, GetResource("L_optSetKmsName"), GetResource("L_ParamsSetKms")) Then
If HandleOptionParam(index+2, False, GetResource("L_optSetKmsName"), GetResource("L_ParamsActivationIDOptional")) Then
SetKmsMachineName WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
Else
SetKmsMachineName WScript.Arguments.Item(index+1), ""
End If
End If
ElseIf strOption = GetResource("L_optClearKmsName") Then
If HandleOptionParam(index+1, False, GetResource("L_optClearKmsName"), GetResource("L_ParamsActivationIDOptional")) Then
ClearKms WScript.Arguments.Item(index+1)
Else
ClearKms ""
End If
ElseIf strOption = GetResource("L_optSetKmsLookupDomain") Then
If HandleOptionParam(index+1, True, GetResource("L_optSetKmsLookupDomain"), GetResource("L_ParamsSetKmsLookupDomain")) Then
If HandleOptionParam(index+2, False, GetResource("L_optSetKmsLookupDomain"), GetResource("L_ParamsActivationIDOptional")) Then
SetKmsLookupDomain WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
Else
SetKmsLookupDomain WScript.Arguments.Item(index+1), ""
End If
End If
ElseIf strOption = GetResource("L_optClearKmsLookupDomain") Then
If HandleOptionParam(index+1, False, GetResource("L_optClearKmsLookupDomain"), GetResource("L_ParamsActivationIDOptional")) Then
ClearKmsLookupDomain WScript.Arguments.Item(index+1)
Else
ClearKmsLookupDomain ""
End If
ElseIf strOption = GetResource("L_optSetKmsHostCaching") Then
SetHostCachingDisable(False)
ElseIf strOption = GetResource("L_optClearKmsHostCaching") Then
SetHostCachingDisable(True)
ElseIf strOption = GetResource("L_optSetActivationInterval") Then
If HandleOptionParam(index+1, True, GetResource("L_optSetActivationInterval"), GetResource("L_ParamsSetActivationInterval")) Then
SetActivationInterval WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optSetRenewalInterval") Then
If HandleOptionParam(index+1, True, GetResource("L_optSetRenewalInterval"), GetResource("L_ParamsSetRenewalInterval")) Then
SetRenewalInterval WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optSetKmsListenPort") Then
If HandleOptionParam(index+1, True, GetResource("L_optSetKmsListenPort"), GetResource("L_ParamsSetListenKmsPort")) Then
SetKmsListenPort WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optSetDNS") Then
SetDnsPublishingDisabled(False)
ElseIf strOption = GetResource("L_optClearDNS") Then
SetDnsPublishingDisabled(True)
ElseIf strOption = GetResource("L_optSetNormalPriority") Then
SetKmsLowPriority(False)
ElseIf strOption = GetResource("L_optClearNormalPriority") Then
SetKmsLowPriority(True)
ElseIf strOption = GetResource("L_optSetVLActivationType") Then
If HandleOptionParam(index+1, False, GetResource("L_optSetVLActivationType"), GetResource("L_ParamsVLActivationTypeOptional")) Then
If HandleOptionParam(index+2, False, GetResource("L_optSetVLActivationType"), GetResource("L_ParamsActivationIDOptional")) Then
SetVLActivationType WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
Else
SetVLActivationType WScript.Arguments.Item(index+1), ""
End If
Else
SetVLActivationType Null, ""
End If
ElseIf strOption = GetResource("L_optListInstalledILs") Then
TkaListILs
ElseIf strOption = GetResource("L_optRemoveInstalledIL") Then
If HandleOptionParam(index+2, True, GetResource("L_optRemoveInstalledIL"), GetResource("L_ParamsRemoveInstalledIL")) Then
TkaRemoveIL WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
End If
ElseIf strOption = GetResource("L_optListTkaCerts") Then
TkaListCerts
ElseIf strOption = GetResource("L_optForceTkaActivation") Then
If HandleOptionParam(index+2, False, GetResource("L_optForceTkaActivation"), GetResource("L_ParamsForceTkaActivation")) Then
TkaActivate WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
ElseIf HandleOptionParam(index+1, True, GetResource("L_optForceTkaActivation"), GetResource("L_ParamsForceTkaActivation")) Then
TkaActivate WScript.Arguments.Item(index+1), ""
End If
ElseIf strOption = GetResource("L_optADGetIID") Then
If HandleOptionParam(index+1, True, GetResource("L_optADGetIID"), GetResource("L_ParamsProductKey")) Then
ADGetIID WScript.Arguments.Item(index+1)
End If
ElseIf strOption = GetResource("L_optADActivate") Then
If HandleOptionParam(index+1, True, GetResource("L_optADActivate"), GetResource("L_ParamsProductKey")) Then
If HandleOptionParam(index+2, False, GetResource("L_optADActivate"), GetResource("L_ParamsAONameOptional")) Then
ADActivateOnline WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2)
Else
ADActivateOnline WScript.Arguments.Item(index+1), ""
End If
End If
ElseIf strOption = GetResource("L_optADApplyCID") Then
If HandleOptionParam(index+1, True, GetResource("L_optADApplyCID"), GetResource("L_ParamsProductKey")) Then
If HandleOptionParam(index+2, True, GetResource("L_optADApplyCID"), GetResource("L_ParamsPhoneActivate")) Then
If HandleOptionParam(index+3, False, GetResource("L_optADApplyCID"), GetResource("L_ParamsAONameOptional")) Then
ADActivatePhone WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2), WScript.Arguments.Item(index+3)
Else
ADActivatePhone WScript.Arguments.Item(index+1), WScript.Arguments.Item(index+2), ""
End If
End If
End If
ElseIf strOption = GetResource("L_optADListAOs") Then
ADListActivationObjects
ElseIf strOption = GetResource("L_optADDeleteAO") Then
If HandleOptionParam(index+1, True, GetResource("L_optADDeleteAO"), GetResource("L_ParamsAODistinguishedName")) Then
ADDeleteActivationObjects WScript.Arguments.Item(index+1)
End If
Else
ParseCommandLine = intUnknownOption
End If
End Function
' global options
Private Function CheckProductForCommand(objProduct, strActivationID)
Dim bCheckProductForCommand
bCheckProductForCommand = False
If (strActivationID = "" And LCase(objProduct.ApplicationId) = WindowsAppId And (objProduct.LicenseIsAddon = False)) Then
bCheckProductForCommand = True
End If
If (LCase(objProduct.ID) = strActivationID) Then
bCheckProductForCommand = True
End If
CheckProductForCommand = bCheckProductForCommand
End Function
Private Sub UninstallProductKey(strActivationID)
Dim objService, objProduct
Dim lRet, strVersion, strDescription
Dim kmsServerFound, uninstallDone
Dim iIsPrimaryWindowsSku, bPrimaryWindowsSkuKeyUninstalled
Dim bCheckProductForCommand
On Error Resume Next
strActivationID = LCase(strActivationID)
kmsServerFound = False
uninstallDone = False
set objService = GetServiceObject("Version")
strVersion = objService.Version
For Each objProduct in GetProductCollection(ProductIsPrimarySkuSelectClause & ", ProductKeyID", PartialProductKeyNonNullWhereClause)
strDescription = objProduct.Description
bCheckProductForCommand = CheckProductForCommand(objProduct, strActivationID)
If (bCheckProductForCommand) Then
iIsPrimaryWindowsSku = GetIsPrimaryWindowsSKU(objProduct)
If (strActivationID = "") And (iIsPrimaryWindowsSku = 2) Then
OutputIndeterminateOperationWarning(objProduct)
End If
objProduct.UninstallProductKey()
QuitIfError()
' Uninstalling a product key could change Windows licensing state.
' Since the service determines if it can shut down and when is the next start time
' based on the licensing state we should reconsume the licenses here.
objService.RefreshLicenseStatus()
' For Windows (i.e. if no activationID specified), always
' ensure that product-key for primary SKU is uninstalled
If (strActivationID <> "") Or (iIsPrimaryWindowsSku = 1) Then
uninstallDone = True
End If
LineOut GetResource("L_MsgUninstalledPKey")
' Check whether a ActID belongs to KMS server.
' Do this for all ActID other than one whose pkey is being uninstalled
ElseIf IsKmsServer(strDescription) Then
kmsServerFound = True
End If
If (kmsServerFound = True) And (uninstallDone = True) Then
Exit For
End If
Next
If kmsServerFound = True Then
' Set the KMS version in the registry (both 64 and 32 bit locations)
lRet = SetRegistryStr(HKEY_LOCAL_MACHINE, SLKeyPath, "KeyManagementServiceVersion", strVersion)
If (lRet <> 0) Then
QuitWithError lRet
End If
lRet = SetRegistryStr(HKEY_LOCAL_MACHINE, SLKeyPath32, "KeyManagementServiceVersion", strVersion)
If (lRet <> 0) Then
QuitWithError lRet
End If
Else
' Clear the KMS version from the registry (both 64 and 32 bit locations)
lRet = DeleteRegistryValue(HKEY_LOCAL_MACHINE, SLKeyPath, "KeyManagementServiceVersion")
If (lRet <> 0 And lRet <> 2) Then
QuitWithError lRet
End If