Superfly-Inc / ShowKeyPlus

Windows product key finder and validation checker
MIT License
930 stars 162 forks source link

Can you add batch capability to create text file? #38

Closed dmcdivitt closed 3 years ago

dmcdivitt commented 3 years ago

Can you possibly add a command line switch such as: /w filename Invoking this way would simply write the file and close.

With this I could script the program and run on several machines without operator intervention. Thank you for writing a nice program.

Superfly-Inc commented 3 years ago

Thanx @dmcdivitt

I'm not sure if you are aware - https://github.com/Superfly-Inc/ShowKeyPlus/releases/tag/ShowKeyPlus7060 has CLI

It does not use a switch just path and filename - I'm not sure if it supports UNC paths - it's been a while since I worked on it.

The current version was designed primarily for UWP so I didn't bother with CLI or Win PE.

If 7060 is terrible let me know - I may export the current MVVM logic to a separate console app. rather that create a hybrid as in the old version.

dmcdivitt commented 3 years ago

I first tried /?, /help, -help and the app opens the same without effect. I made a shortcut, put arguments in the shortcut, then tried from a command window.

After your email I tried with just a file name as argument and that does not appear to do anything.

I attached a screen snapshot of the exe file properties.

-- yes, I dare to be subjective!

On 4/14/2021 11:04 AM, Craig - Superfly wrote:

Thanx @dmcdivitt https://github.com/dmcdivitt

I'm not sure if you are aware - https://github.com/Superfly-Inc/ShowKeyPlus/releases/tag/ShowKeyPlus7060 https://github.com/Superfly-Inc/ShowKeyPlus/releases/tag/ShowKeyPlus7060 has CLI

It does use a switch just path and filename - I'm not sure if it supports UNC paths - it's been a while since I worked on it.

The current version was designed primarily for UWP so I didn't bother with CLI or Win PE.

If 7060 is terrible let me know - I may export the current MVVM logic to a separate console app. rather that create a hybrid as in the old version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Superfly-Inc/ShowKeyPlus/issues/38#issuecomment-819633832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCMWY4IT6TRDXECVXJW63TIW4HNANCNFSM425OK7MA.

Superfly-Inc commented 3 years ago

OK, strange tho' as I tested it and it worked

PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe /?

OutFile - Specifies the path, filename and file extension of the file to which product key information saved Text file extensions only supported (eg. txt, doc, docx, csv etc)

Created the test file as well PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe C:\Users\Craig\Desktop\test.txt PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> File saved as C:\Users\Craig\Desktop\test.txt

dmcdivitt commented 3 years ago

On page github.com/Superfly-Inc/ShowKeyPlus I clicked "latest". It gave me the verbiage pasted below saying it does not have CLI and to use version 1.0.7060 if you want that. So I clicked the "+ 4 releases" link, found 1.0.7060 and downloaded that. That version prompts for admin privileges while the latest version does not.

Version 1.0.7060 gave some strange behavior, though. I tested by making a shortcut and putting /? as an argument. When I clicked the shortcut it asked for admin rights, I entered the admin password, then it asked for admin rights again, I entered the admin password again, and it kept doing that. So I opened a command window and tried. It asked for admin rights then proceeded ok. Again, very strange behavior and you should know.

I will use version 1.0.7060 since it has what I want. Thanks again for making the program!

----- FROM PAGE:

This version applies to Windows 8 and 10 only

Windows 7 is no longer supported (apart from key checking).

It does not have WinPE, CLI functionality - please continue using ShowKeyPlus Version: 1.0.7060 for those features

Whats new:

-- yes, I dare to be subjective!

On 4/14/2021 2:49 PM, Craig - Superfly wrote:

OK, strange tho' as I tested it and it worked

PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe /?

OutFile - Specifies the path, filename and file extension of the file to which product key information saved Text file extensions only supported (eg. txt, doc, docx, csv etc)

Created the test file as well PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe C:\Users\Craig\Desktop\test.txt PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> File saved as C:\Users\Craig\Desktop\test.txt

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Superfly-Inc/ShowKeyPlus/issues/38#issuecomment-819788361, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCMW2ZHOYMYMKYUV2AHQLTIXWWNANCNFSM425OK7MA.

dmcdivitt commented 3 years ago

You know I described how version 1.0.7060 keeps prompting for admin rights over and over. I made vbscript to collect a lot of stuff from my machines. I remote in, run the script from a shared folder on the LAN, it saves to desktop, then because I remote in I can copy and paste the file back to my main machine.

So I included ShowKeyPlus in the vbscript. It keeps prompting for admin rights over and over. To troubleshoot I put a msgbox after the shell to ShowKeyPlus. ShowKeyPlus prompts for admin password, I enter that, it runs, the msgbox appears, then ShowKeyPlus runs again! I played with it to see what it would do. I tried entering the admin password again and again and it would go on forever. I tried clicking OK at the msgbox instead of entering the admin password. The msgbox did not have focus so I had to find it. If I did that the script would finish. But if I clicked no at the admin prompt the vbscript would generate an error saying the run command canceled. Strange because it appeared to have finished. Strange how the script run method when told to wait for complete would continue from ShowKeyPlus , but on a subsequent admin prompt for ShowKeyPlus when I clicked no, it would throw an error, as if the vbscript began running a new thread.

Anyway, I have included the vbscript. Remove the .txt from the end after saving. Please disregard the ConvertToKey routine. I copied that from the internet and chose to leave as is. I would not write code like that. To run the vbscript set up a user without admin rights and run with that user.

-- yes, I dare to be subjective!

On 4/14/2021 5:59 PM, David McDivitt wrote:

On page github.com/Superfly-Inc/ShowKeyPlus I clicked "latest". It gave me the verbiage pasted below saying it does not have CLI and to use version 1.0.7060 if you want that. So I clicked the "+ 4 releases" link, found 1.0.7060 and downloaded that. That version prompts for admin privileges while the latest version does not.

Version 1.0.7060 gave some strange behavior, though. I tested by making a shortcut and putting /? as an argument. When I clicked the shortcut it asked for admin rights, I entered the admin password, then it asked for admin rights again, I entered the admin password again, and it kept doing that. So I opened a command window and tried. It asked for admin rights then proceeded ok. Again, very strange behavior and you should know.

I will use version 1.0.7060 since it has what I want. Thanks again for making the program!

----- FROM PAGE:

This version applies to Windows 8 and 10 only

Windows 7 is no longer supported (apart from key checking).

It does not have WinPE, CLI functionality - please continue using ShowKeyPlus Version: 1.0.7060 for those features

Whats new:

  • Re-design to be consistent with Store version
  • "More" and "Upgrades" search for additional and previous installations respectively.

-- yes, I dare to be subjective! On 4/14/2021 2:49 PM, Craig - Superfly wrote:

OK, strange tho' as I tested it and it worked

PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe /?

OutFile - Specifies the path, filename and file extension of the file to which product key information saved Text file extensions only supported (eg. txt, doc, docx, csv etc)

Created the test file as well PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> C:\Users\Craig\Desktop\ShowKeyPlus_x64\ShowKeyPlus.exe C:\Users\Craig\Desktop\test.txt PS C:\Users\Craig\Desktop\ShowKeyPlus_x64> File saved as C:\Users\Craig\Desktop\test.txt

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Superfly-Inc/ShowKeyPlus/issues/38#issuecomment-819788361, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCMW2ZHOYMYMKYUV2AHQLTIXWWNANCNFSM425OK7MA.

const ToRead = 1 const ToWrite = 2 const ToAppend = 8 const exe = "ShowKeyPlus.1.0.7060.exe" script_name = mid(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")) script_path = left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"\")) set fso = createobject("Scripting.FileSystemObject") if not fso.fileexists(script_path & exe) then msgbox exe & " not found" wscript.quit end if set ws = createobject("WScript.Shell") desktop = ws.expandenvironmentstrings("%USERPROFILE%") & "\Desktop" temp_file = desktop & "\" & exe & ".txt" harvesting = true while harvesting harvesting = false ws.run """" & script_path & exe & """ """ & temp_file & """",1,true msgbox "waiting" wad = "" if fso.fileexists(temp_file) then with fso.opentextfile(temp_file,ToRead) wad = .readall .close end with fso.deletefile tempfile end if if len(wad) = 0 then select case msgbox("Output from " & exe & " was not found" & vbcrlf & "on the desktop." & vbcrlf & vbcrlf & _ "Try again?",vbYesNoCancel) case vbNo case vbYes harvesting = true case else wscript.quit end select end if wend machine = ws.expandenvironmentstrings("%COMPUTERNAME%") file_name = desktop & script_name & "." & machine & ".txt" with fso.createtextfile(file_name,true) .writeline machine on error resume next key = ws.regread("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId") sw = err = 0 on error goto 0 if sw then a = ConvertToKey(key) else a = "no value found" .writeline "DigitalProductId: " & a on error resume next key = ws.regread("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId4") sw = err = 0 on error goto 0 if sw then a = ConvertToKey(key) else a = "no value found" .writeline "DigitalProductId4: " & a .writeline "" .writeline replace(wad,vbcrlf & vbcrlf,vbcrlf) .close end with ws.run "cmd /c cscript C:\Windows\System32\slmgr.vbs /dlv >>""" & file_name & """",1,true ws.run "cmd /c cscript C:\Windows\System32\slmgr.vbs /xpr >>""" & file_name & """",1,true

Function ConvertToKey(Key) Const KeyOffset = 52 i = 28 Chars = "BCDFGHJKMPQRTVWXY2346789" Do Cur = 0 x = 14 Do Cur = Cur * 256 Cur = Key(x + KeyOffset) + Cur Key(x + KeyOffset) = (Cur \ 24) And 255 Cur = Cur Mod 24 x = x -1 Loop While x >= 0 i = i -1 KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput If (((29 - i) Mod 6) = 0) And (i <> -1) Then i = i -1 KeyOutput = "-" & KeyOutput End If Loop While i >= 0 ConvertToKey = KeyOutput End Function

Superfly-Inc commented 3 years ago

Thanx for that feedback - I will test a few scenarios. CLI was not extensively tested - back then we were more concerned about Win PE. Anyway 7060 is deprecated - so as I said, if need be I'd rather create a new CLI-centric app.

(PS That vbs brings back memories of my ASP days, yes before ASP .Net )

Superfly-Inc commented 3 years ago

I decided not to pursue a new CLI version for the time-being.