Jeffery Posted April 10, 2014 Author Share Posted April 10, 2014 To simulate this problem it is important to migrate the RunAs script and the Key Changer together and on Windows 7 UAC needs to be turned on or you have to be on a guest account without admin rights to simulate this problem. Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2014 Share Posted April 10, 2014 I tried my test on Win 7 UAC enable on account that had only user rights. The hta in my script needed an admin account to make the changes to the registry keys, I was able to make the changes on that regular user account. Link to comment Share on other sites More sharing options...
bphlpt Posted April 10, 2014 Share Posted April 10, 2014 And it seems that the only difference between GSM's tests and that of Jeffery, is that GSM calls the external KeyChanger script while Jeffery tried to put it inline. Do I understand that correctly? Jeffery, if you try to break the KeyChanger script out into a separate file does that work correctly? I know you want it as a single file, but does it work as two files?Cheers and Regards Link to comment Share on other sites More sharing options...
Jeffery Posted April 10, 2014 Author Share Posted April 10, 2014 If i break the KeyChanger script out into a separate file then it works but as soon as i put them together in one file then they won't love each other anymore. Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2014 Share Posted April 10, 2014 Since I dont want to write the whole things for you, not my job I will point you in a direction that might help you. I added a function to the script from Stackoverflow that I called Input. Dim A Set reg = GetObject("winmgmts://./root/default:StdRegProv")rc = reg.GetStringValue(&h80000003, "S-1-5-19\Environment", "TEMP", val)If rc = 5 Then 'return code 5 == access denied 're-launch script only when it was run without arguments, so we don't go 'in circles when admin privileges can't be acquired If WScript.Arguments.Count = 0 Then 're-launch as administrator; the additional argument is a guard to make 'sure the script is re-launched only once CreateObject("Shell.Application").ShellExecute "wscript.exe" _ , Chr(34) & WScript.ScriptFullName & Chr(34) & " relaunch", "", "runas", 1 WScript.Quit 0 Else WScript.Echo "Cannot acquire admin privileges." WScript.Quit 1 End IfElse 'your code here ' CreateObject("Wscript.Shell").Run("C:\Users\Gunsmokingman\Desktop\RegistrationChanger.hta"),1,True ' CreateObject("Wscript.Shell").Run("powerCfg -H Off") Input() WScript.Echo AEnd If Function Input() Input=InputBox( _ "Type In The New Key In This Format 12345-54321-12345-ABCDE-1A2B3.") If Len(Input) = 29 Then A = Input If Not Len(Input) = 29 Then If MsgBox( _ "Does Not Appear To Have 29 Characters : " & Len(Input) & vbCrLf & _ "Would You Like To Redo Your Input, Yes To Redo," & vbCrLf & _ "No To Exit And Do Nothing?",4132,"Redo Or Quit") = 6 Then Input() Else WScript.Quit End If End If End Function Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2014 Share Posted April 10, 2014 Nobody has yet answered my basic question! What is the point of the flow of this Topic? A Windows XP key changing script on Windows 7 Link to comment Share on other sites More sharing options...
jaclaz Posted April 10, 2014 Share Posted April 10, 2014 To expand on Yzöwl's question, according to this: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394520(v=vs.85).aspx Requirements Minimum supported client Windows XP Minimum supported server Windows Server 2003 End of client support Windows XP End of server support Windows Server 2003 R2the win32_WindowsProductActivation class is non-existing on non-XP/2003. jaclaz Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2014 Share Posted April 10, 2014 Nobody has yet answered my basic question! What is the point of the flow of this Topic? A Windows XP key changing script on Windows 71:\ The user was asking for help on how to make the script work correct. 2:\ My understanding is that the user want to change some product keys on some OS that seems to have UAC enable. 3:\ Jaclaz your wrong List Windows Product Activation Status Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2014 Share Posted April 10, 2014 I do hope that both parties are sure of their facts......I'm staying out of this, but I know which one is correct! Link to comment Share on other sites More sharing options...
jaclaz Posted April 10, 2014 Share Posted April 10, 2014 (edited) 2:\ My understanding is that the user want to change some product keys on some OS that seems to have UAC enable.My understanding is very similar to yours, though I suspect that the OP is slipping (and indirectly bringing down you with him ) on a chocolate-covered banana , just in case:http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/put-down-the-chocolate-covered-banana.html3:\ Jaclaz your wrong List Windows Product Activation Status I may be (rare, but it can happen ), but I did not actually state anything, I simply reported a source "as is".Just for the record here:http://gallery.technet.microsoft.com/scriptcenter/3209f9b8-842e-43a8-a36a-575226b6e8edthere is this text:Verified on the following platformsWindows Server 2012 NoWindows Server 2008 R2 NoWindows Server 2008 NoWindows Server 2003 YesWindows 8 NoWindows 7 NoWindows Vista NoWindows XP YesWindows 2000 Nowhich may also be "wrong", but it is possibly a hint that the referenced page is actually "right" And, JFYI:http://sqlblog.com/blogs/aaron_bertrand/archive/2011/03/13/ot-windows-activation-en-masse.aspxWhenever I do anything with this number of machines, I assume there's an easy way to do it in PowerShell. My searching throughout the 'toobz led to many promising scripts; unfortunately, most dealt with the old WMI class used prior to Windows 7 and Windows Server 2008 R2: Win32_WindowsProductActivation. In the latest versions of the operating system, trying to utilize this class leads to generic "Invalid Class" errors; the methods and properties associated with this class have been split out into two new classes: SoftwareLicensingProduct and SoftwareLicensingService (did I mention I'm really glad they're moving away from the Win32_ prefix?).jaclaz Edited April 10, 2014 by jaclaz Link to comment Share on other sites More sharing options...
bphlpt Posted April 10, 2014 Share Posted April 10, 2014 (edited) I'll accept at least part of the blame for getting Win7 "involved" in this thread when it would seem the script is supposed to be used on an XP system to change the XP product key.I don't have an XP system to use for testing, but I figured that I could at least see if the logic used in the OP VBS seemed to function. So I tried it in my Win7 system, specified that I was using Win7 in my test, and specified that I cancelled the script without executing the Key Changer portion, but it did seem to bring it up appropriately once I added the "missing" last line of the script. I did this test since the original complaint was that he couldn't seem to get past the Admin rights check portion. I reported that I could so I didn't understand why the problem was occurring.If my testing methods confused the issue I apologize.EDIT: Thanks to jaclaz for finding the following:http://www.imdb.com/title/tt0095159/quotes?item=qt0320188I do, I offer a complete and utter retraction. The imputation was totally without basis in fact, and was in no way fair comment, and was motivated purely by malice, and I deeply regret any distress that my comments may have caused you, or your family, and I hereby undertake not to repeat any such slander at any time in the future.Cheers and Regards Edited April 11, 2014 by bphlpt Link to comment Share on other sites More sharing options...
jaclaz Posted April 10, 2014 Share Posted April 10, 2014 If my testing methods confused the issue I apologize.http://www.imdb.com/title/tt0095159/quotes?item=qt0320188I do, I offer a complete and utter retraction. The imputation was totally without basis in fact, and was in no way fair comment, and was motivated purely by malice, and I deeply regret any distress that my comments may have caused you, or your family, and I hereby undertake not to repeat any such slander at any time in the future.Hmmm , I wonder where exactly you found that link and quote . jaclaz Link to comment Share on other sites More sharing options...
bphlpt Posted April 10, 2014 Share Posted April 10, 2014 Thought you would like that.Cheers and Regards Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 11, 2014 Share Posted April 11, 2014 1:\ Thanks to Jaclaz for pointing the correct WMI object2:\ Tested this on Windows 7 as admin and as User, works I had to supply the admin stuff threw UAC GUI, with no errors.3:\ Tested this same way on Windows Vista no errors.RunAsKeyChanger.vbs'-> Script By Gunsmokingman AKA Jake1Eye'-> This Script And Or Any Code Is The Property Of Gunsmokingman Or'-> Jake1Eye, Except Where Acknowledgement Comments Exists for Code'-> Written By Other Coders.'-> If Any Part Of This Code Is Used In Other Coding Project, There'-> Must Be An Acknowledgement Comments To The Original Coder Must Be '-> Included In Any Other Coding Project.'-> Objects For Runtime Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\cimv2")'-> Varible For RunTime Dim A, Obj, R'-> Original Link To Script At StackOverFlow'-> http://stackoverflow.com/questions/18504036/is-is-possible-to-have-run-as-prompt-for-vbscript'-> Script Modified By Gunsmokingman Aka Jake1eye Set reg = GetObject("winmgmts://./root/default:StdRegProv") rc = reg.GetStringValue(&h80000003, "S-1-5-19\Environment", "TEMP", val) If rc = 5 Then'-> return code 5 == access denied, re-launch script only when it was run without arguments, '-> so we don't goin circles when admin privileges can't be acquired If WScript.Arguments.Count = 0 Then'-> re-launch as administrator; the additional argument is a guard to make'-> sure the script is re-launched only once CreateObject("Shell.Application").ShellExecute "wscript.exe" _ , Chr(34) & WScript.ScriptFullName & Chr(34) & " relaunch", "", "runas", 1 WScript.Quit 0 Else Msgbox "Cannot acquire admin privileges.",4128,"Admin Access denied" WScript.Quit 1 End If Else'-> Code Here To Run Elevated Input() ConfirmChange(A) End If'-> Function To Get The New Replace Key Function Input() Input=InputBox( _ "Type In The New Key In This Format 12345-54321-12345-ABCDE-1A2B3.") If Len(Input) = 29 Then A = Input If Not Len(Input) = 29 Then If MsgBox( _ "Does Not Appear To Have 29 Characters : " & Len(Input) & vbCrLf & _ "Would You Like To Redo Your Input, Yes To Redo," & vbCrLf & _ "No To Exit And Do Nothing?",4132,"Redo Or Quit") = 6 Then Input() Else WScript.Quit End If End If End Function '-> Confirm The Changes Function ConfirmChange(K) Dim Os If MsgBox( _ "Did you want to continue with changing the OS Product Key?" & vbCrLf & _ "Yes to continue and change the OS Product Key, No to exit" & vbCrLf & _ "and make no changes to the OS Product Key",4132,"Continue Or Stop") = 6 Then For Each Obj In Wmi.ExecQuery("SELECT * FROM win32_OperatingSystem") Os = Obj.Caption Next If InStr(1,Os,"XP",1) Then OsX(Replace(K,"-","")) If InStr(1,Os,"7",1) Or InStr(1,Os,"Vista",1)Then V7(K) Else WScript.Quit End If End Function '-> Original Link To Script At PasteBin'-> http://pastebin.com/Wp5cCsHk'-> Script Modified By Gunsmokingman Aka Jake1eye'-> For XP Function OsX(K) On Error Resume Next For Each Obj In Wmi.ExecQuery("SELECT * FROM win32_WindowsProductActivation") R = Obj.SetProductKey(K) If Err = 0 Then MsgBox "Key Has Been Change",4128,"Success" If Err <> 0 Then MsgBox "An Error entering the new OS Product Key" & vbCrLf & _ "Key Enter : " & K & vbCrLf & "Verify that this is the correct or valid" & vbCrLf & _ "OS Product Key",4128,"Key Error" Next End Function'-> Tested On Win 7 And Vista Function V7(K) For Each Obj In Wmi.ExecQuery("SELECT * FROM SoftwareLicensingService") R = Obj.InstallProductKey(K) If Err = 0 Then MsgBox "Key Has Been Change",4128,"Success" If Err <> 0 Then MsgBox "An Error entering the new OS Product Key" & vbCrLf & _ "Key Enter : " & K & vbCrLf & "Verify that this is the correct or valid" & vbCrLf & _ "OS Product Key",4128,"Key Error" Next End Function Rename RunAsKeyChanger.vbs.txt to RunAsKeyChanger.vbs to make activeRunAsKeyChanger.vbs.txt Link to comment Share on other sites More sharing options...
Jeffery Posted April 11, 2014 Author Share Posted April 11, 2014 (edited) gunsmokingman, i test your script on Windows XP and it is working without any problems. Adding this 2 scripts together looks more complicated than i expected it to be. Edited April 11, 2014 by Jeffery Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now