<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS - запись ключа windows в текстовый файл]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7972&amp;type=atom" />
	<updated>2013-01-13T05:49:55Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7972</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS - запись ключа windows в текстовый файл]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68431#p68431" />
			<content type="html"><![CDATA[<p>OFF:<br /></p><div class="quotebox"><cite>omegastripes пишет:</cite><blockquote><p>или читабельный вариант:</p></blockquote></div><p>На мой взгляд, первый вариант на порядок понятнее.</p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2013-01-13T05:49:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68431#p68431</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS - запись ключа windows в текстовый файл]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68425#p68425" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[omegastripes]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=29228</uri>
			</author>
			<updated>2013-01-12T19:06:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68425#p68425</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS - запись ключа windows в текстовый файл]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=68421#p68421" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[ddp]]></name>
			</author>
			<updated>2013-01-12T09:36:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=68421#p68421</id>
		</entry>
</feed>
