<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; CMD/BAT: Поиск в реестре по дате]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7761&amp;type=atom" />
	<updated>2012-11-08T14:49:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7761</id>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65468#p65468" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>netrezv пишет:</cite><blockquote><p>вариант на PS</p></blockquote></div><p>Хм... код размашист. Лучше все WinAPI вызовы в одну сигнатуру прибрать - все равно же обращение будет по NameSpace, хотя на Вашем месте бы я вообще всю логику описал в сигнатуре, сведя тем самым до минимума обращение к определенным в ней функциям. Но это лишь мое мнение. В целом, молодцом! Можно даже в коллекцию.<br />Непосредственно по теме.<br />У самого была необходимость извлекать подобные данные. В Far&#039;е для этого есть плагин, а вот с комстрокой не все так просто. Хочется написать программку, да времени не хватает катастрофически на все про все.</p>]]></content>
			<author>
				<name><![CDATA[greg zakharov]]></name>
			</author>
			<updated>2012-11-08T14:49:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65468#p65468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65459#p65459" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Rom5 пишет:</cite><blockquote><p>Только в текстовый файл можно, имхо, только с GUI regedit выгрузить.</p><p><em>Имеется в виду именно та разновидность TXT-файла, которая с датами.</em></p></blockquote></div><p>Все верно и только в TXT, не знал об этом. Вдруг кому-то пригодится, вариант на PS<br /></p><div class="codebox"><pre><code>#Set-ExecutionPolicy Unrestricted - Разрешается выполнение любых сценариев PowerShell без проверки цифровой подписи.

param (    [string] $Key, [string] $SubKey )

switch ($Key) {
    &quot;HKCR&quot; { $searchKey = 0x80000000} #HK Classes Root
    &quot;HKCU&quot; { $searchKey = 0x80000001} #HK Current User
    &quot;HKLM&quot; { $searchKey = 0x80000002} #HK Local Machine
    &quot;HKU&quot;  { $searchKey = 0x80000003} #HK Users
    &quot;HKCC&quot; { $searchKey = 0x80000005} #HK Current Config
    default { 
        #throw &quot;Invalid Key. Use one of the following options HKCR, HKCU, HKLM, HKU, HKCC&quot;
    }
}


$KEYQUERYVALUE = 0x1
$KEYREAD = 0x19
$KEYALLACCESS = 0x3F

$sig1 = @&#039;
[DllImport(&quot;advapi32.dll&quot;, CharSet = CharSet.Auto)]
  public static extern int RegOpenKeyEx(
    int hKey,
    string subKey,
    int ulOptions,
    int samDesired,
    out int hkResult);
&#039;@
$type1 = Add-Type -MemberDefinition $sig1 -Name Win32Utils `
    -Namespace RegOpenKeyEx -Using System.Text -PassThru

$sig2 = @&#039;
[DllImport(&quot;advapi32.dll&quot;, EntryPoint = &quot;RegEnumKeyEx&quot;)]
extern public static int RegEnumKeyEx(
    int hkey,
    int index,
    StringBuilder lpName,
    ref int lpcbName,
    int reserved,
    int lpClass,
    int lpcbClass,
    out long lpftLastWriteTime);
&#039;@
$type2 = Add-Type -MemberDefinition $sig2 -Name Win32Utils `
    -Namespace RegEnumKeyEx -Using System.Text -PassThru

$sig3 = @&#039;
[DllImport(&quot;advapi32.dll&quot;, SetLastError=true)]
public static extern int RegCloseKey(
    int hKey);
&#039;@
$type3 = Add-Type -MemberDefinition $sig3 -Name Win32Utils `
    -Namespace RegCloseKey -Using System.Text -PassThru


$hKey = new-object int
$result = $type1::RegOpenKeyEx($searchKey, $SubKey, 0, $KEYREAD, [ref] $hKey)

#initialize variables
$builder = New-Object System.Text.StringBuilder 1024
$index = 0
$length = [int] 1024
$time = New-Object Long

#234 means more info, 0 means success. Either way, keep reading
while ( 0,234 -contains $type2::RegEnumKeyEx($hKey, $index++, `
    $builder, [ref] $length, $null, $null, $null, [ref] $time) )
{
    #create output object
    $o = &quot;&quot; | Select Key, LastWriteTime
    $o.Key = $builder.ToString()
    $o.LastWriteTime = (Get-Date $time).AddYears(1600)
    $o

    #reinitialize for next time through the loop  
    $length = [int] 1024
    $builder = New-Object System.Text.StringBuilder 1024
}

$result = $type3::RegCloseKey($hKey);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[netrezv]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27040</uri>
			</author>
			<updated>2012-11-08T07:11:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65459#p65459</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65458#p65458" />
			<content type="html"><![CDATA[<p>Только в текстовый файл можно, имхо, только с GUI regedit выгрузить.</p><p><em>Имеется в виду именно та разновидность TXT-файла, которая с датами.</em></p>]]></content>
			<author>
				<name><![CDATA[Rom5]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5724</uri>
			</author>
			<updated>2012-11-08T06:59:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65458#p65458</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65455#p65455" />
			<content type="html"><![CDATA[<p>Для комстроки есть команда REG:<br />&gt;reg export /?</p>]]></content>
			<author>
				<name><![CDATA[Serge Yolkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27503</uri>
			</author>
			<updated>2012-11-08T05:16:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65455#p65455</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65452#p65452" />
			<content type="html"><![CDATA[<p>Без понятия...<br />Но REGEDIT позволяет делать экспорт выбранного раздела реестра в тектовый файл, содержащий последнее время записи каждого из подразделов. (Не знаю, существуют ли ключи, чтобы это сделать из командной строки.)</p><p>Затем этот файл можно открыть в текстовом редакторе и произвести поиск по требуемой дате. А можно написать командный файл для этой цели. Файл создаётся в юникоде, для преобразования его в кодировку DOS можно использовать команду TYPE.</p>]]></content>
			<author>
				<name><![CDATA[shiz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26249</uri>
			</author>
			<updated>2012-11-08T01:06:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65452#p65452</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[CMD/BAT: Поиск в реестре по дате]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=65442#p65442" />
			<content type="html"><![CDATA[<p>Есть ли консольные средства? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> (знаю на ps можно, к тому же есть гуёвые RegCmd.exe? и RegScanner.exe)</p>]]></content>
			<author>
				<name><![CDATA[netrezv]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27040</uri>
			</author>
			<updated>2012-11-07T06:18:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=65442#p65442</id>
		</entry>
</feed>
