<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS - запись ключа windows в текстовый файл]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=7972</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7972&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS - запись ключа windows в текстовый файл».]]></description>
		<lastBuildDate>Sun, 13 Jan 2013 05:49:55 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS - запись ключа windows в текстовый файл]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=68431#p68431</link>
			<description><![CDATA[<p>OFF:<br /></p><div class="quotebox"><cite>omegastripes пишет:</cite><blockquote><p>или читабельный вариант:</p></blockquote></div><p>На мой взгляд, первый вариант на порядок понятнее.</p>]]></description>
			<author><![CDATA[null@example.com (wisgest)]]></author>
			<pubDate>Sun, 13 Jan 2013 05:49:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=68431#p68431</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS - запись ключа windows в текстовый файл]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=68425#p68425</link>
			<description><![CDATA[<div class="codebox"><pre><code>with createobject(&quot;scripting.filesystemobject&quot;).createtextfile(createobject(&quot;wscript.shell&quot;).expandenvironmentstrings(&quot;%TEMP%\1.txt&quot;), true)
    .write(Win8ProductKey)
    .close
end with</code></pre></div><p>или читабельный вариант:</p><div class="codebox"><pre><code>dim shell, filename, fso, textfile
set shell = createobject(&quot;wscript.shell&quot;)
filename = shell.expandenvironmentstrings(&quot;%TEMP%\1.txt&quot;)
set shell = nothing
set fso = createobject(&quot;scripting.filesystemobject&quot;)
set textfile = fso.createtextfile(filename, true)
textfile.write(win8productkey)
textfile.close
set textfile = nothing
set fso = nothing</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (omegastripes)]]></author>
			<pubDate>Sat, 12 Jan 2013 19:06:06 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=68425#p68425</guid>
		</item>
		<item>
			<title><![CDATA[VBS - запись ключа windows в текстовый файл]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=68421#p68421</link>
			<description><![CDATA[<p>Добрый день. Подскажите пожалуйста, имеется vbs скрипт для определения ключа продукта Windows. Он выводит его в сообщение [MsgBox(Win8ProductKey)]. Как сделать, чтобы он записал его в текстовый файл во временную папку (скажем %TEMP%\1.txt)? Заранее спасибо.</p><p>Скрипт:<br /></p><div class="codebox"><pre><code>Set WshShell = CreateObject(&quot;WScript.Shell&quot;)
regKey = &quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\&quot;
DigitalProductId = WshShell.RegRead(regKey &amp; &quot;DigitalProductId&quot;)
 
Win8ProductName = &quot;Windows Product Name: &quot; &amp; WshShell.RegRead(regKey &amp; &quot;ProductName&quot;) &amp; vbNewLine
Win8ProductID = &quot;Windows Product ID: &quot; &amp; WshShell.RegRead(regKey &amp; &quot;ProductID&quot;) &amp; vbNewLine
Win8ProductKey = ConvertToKey(DigitalProductId)
strProductKey =&quot;Windows 8 Key: &quot; &amp; Win8ProductKey 
Win8ProductID = Win8ProductName &amp; Win8ProductID &amp; strProductKey 
 
MsgBox(Win8ProductKey)

 
Function ConvertToKey(regKey)
    Const KeyOffset = 52
    isWin8 = (regKey(66) \ 6) And 1
    regKey(66) = (regKey(66) And &amp;HF7) Or ((isWin8 And 2) * 4)
    j = 24
    Chars = &quot;BCDFGHJKMPQRTVWXY2346789&quot;
    Do
        Cur = 0
        y = 14
        Do
            Cur = Cur * 256
            Cur = regKey(y + KeyOffset) + Cur
            regKey(y + KeyOffset) = (Cur \ 24)
            Cur = Cur Mod 24
            y = y -1
        Loop While y &gt;= 0
        j = j -1
        winKeyOutput = Mid(Chars, Cur + 1, 1) &amp; winKeyOutput
        Last = Cur
    Loop While j &gt;= 0
    If (isWin8 = 1) Then
        keypart1 = Mid(winKeyOutput, 2, Last)
        insert = &quot;N&quot;
        winKeyOutput = Replace(winKeyOutput, keypart1, keypart1 &amp; insert, 2, 1, 0)
        If Last = 0 Then winKeyOutput = insert &amp; winKeyOutput
    End If
    a = Mid(winKeyOutput, 1, 5)
    b = Mid(winKeyOutput, 6, 5)
    c = Mid(winKeyOutput, 11, 5)
    d = Mid(winKeyOutput, 16, 5)
    e = Mid(winKeyOutput, 21, 5)
    ConvertToKey = a &amp; &quot;-&quot; &amp; b &amp; &quot;-&quot; &amp; c &amp; &quot;-&quot; &amp; d &amp; &quot;-&quot; &amp; e
End Function</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ddp)]]></author>
			<pubDate>Sat, 12 Jan 2013 09:36:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=68421#p68421</guid>
		</item>
	</channel>
</rss>
