<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Безопасно вытащить USB]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=8262</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8262&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Безопасно вытащить USB».]]></description>
		<lastBuildDate>Wed, 19 Jun 2013 12:51:27 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73114#p73114</link>
			<description><![CDATA[<p>Спасибо за развернутое объяснение.<br />Начал понимать <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Сейчас фрагмент кода по выгружению usb выглядит так и вроде работает<br /></p><div class="codebox"><pre><code>
copyDest = Z:
watchfolder = D:\Abola\TEMP_HDD
FileRemoveDir, %watchfolder%, 1
FileCreateDir, %watchfolder%
FileAppend, list volume, %watchfolder%\hdd1.txt
Runwait, %comspec% /c &quot;&quot;DISKPART.exe&quot; &quot;/s&quot; &quot;%watchfolder%\hdd1.txt&quot; &gt; &quot;%watchfolder%\hdd2.txt&quot;&quot;
FileRead, DiskPart, %watchfolder%\hdd2.txt
RegExMatch(DiskPart, &quot;\R\s+Volume\s+(\d+)\s+\w\s+USB_HDD\s+&quot;, Match)
FileAppend, select volume %Match1%`nremove all dismount, %watchfolder%\hdd3.txt
Runwait, %comspec% /c &quot;&quot;DISKPART.exe&quot; &quot;/s&quot; &quot;%watchfolder%\hdd3.txt&quot;&quot;
FileAppend, select volume %Match1%`nassign letter=%copyDest%, %watchfolder%\hdd4.txt
Runwait, %comspec% /c &quot;&quot;DISKPART.exe&quot; &quot;/s&quot; &quot;%watchfolder%\hdd4.txt&quot;&quot;
FileRemoveDir, %watchfolder%, 1
RunWait, D:\Abola\USB_HDD\RemUMS.exe %copyDest%   ; безопасно выгружаем usb
MsgBox, 4096, USB_HDD, DONE!
ExitApp 
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 19 Jun 2013 12:51:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73114#p73114</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73104#p73104</link>
			<description><![CDATA[<p>Шаблон можно поправить на:<br /></p><div class="codebox"><pre><code>&quot;\R\s+Volume\s+(\d+)\s+(\w)\s+Backup\s+&quot;</code></pre></div><p>Тут всё очень просто: Ищется строка указанная в шаблоне.<br />То есть кусок текста из переменной где подряд идут:<br />\R - перенос строки<br />\s+ - один и более пробельных символов<br />Volume - слово Volume<br />\s+ - один и более пробельных символов<br />\d+ - одна и более цифр<br />\s+ - один и более пробельных символов<br />\w - одна буква<br />\s+ - один и более пробельных символов<br />Backup - слово Backup<br />\s+ - один и более пробельных символов</p><p><span class="bbu">Так как:</span><br />\d+ заключена в скобки, её содержимое в найденной подстроке будет в Match1.<br />\w заключена в скобки после \d+, её содержимое будет в Match2.<br />Сама найденная строка в Match.</p><div class="codebox"><pre><code>RegExMatch(DiskPart, &quot;\R\s+Volume\s+(\d+)\s+(\w)\s+Backup\s+&quot;, Match)
MsgBox % Match
MsgBox % Match1
MsgBox % Match2</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 19 Jun 2013 09:55:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73104#p73104</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73098#p73098</link>
			<description><![CDATA[<p>Спасибо огромное!<br />Я к сожалению RegEx не понимаю.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 19 Jun 2013 09:32:20 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73098#p73098</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73095#p73095</link>
			<description><![CDATA[<p>Номер же надо, а не букву.<br /></p><div class="codebox"><pre><code>RegExMatch(DiskPart, &quot;.*?\R\s+Volume\s+(\d+)\s+(\w)\s+Backup\s+.*&quot;, Match)
MsgBox % Match1
MsgBox % Match2

</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 19 Jun 2013 09:23:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73095#p73095</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73093#p73093</link>
			<description><![CDATA[<div class="codebox"><pre><code>
DiskPart =
(
Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: TV-PC

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     X                       DVD-ROM         0 B  No Media           
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System  
  Volume 2     C                NTFS   Partition    465 GB  Healthy    Boot    
  Volume 3     D                NTFS   Partition    931 GB  Healthy    Pagefile
  Volume 4     G   Backup       NTFS   Partition   2794 GB  Healthy            
  Volume 5     F   Backup       NTFS   Partition   2794 GB  Healthy            
  Volume 6                             Partition   2794 GB  Healthy    Offline 
)
RegExMatch(DiskPart, &quot;.*?\R\s+Volume\s+\d+\s+(\w)\s+Backup\s+.*&quot;, Match)
MsgBox % Match1
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 19 Jun 2013 09:20:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73093#p73093</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73091#p73091</link>
			<description><![CDATA[<p>Вот, что удалось написать<br /></p><div class="codebox"><pre><code>watchfolder = C:\1
FileRemoveDir, %watchfolder%, 1
FileCreateDir, %watchfolder%
FileAppend, list volume, %watchfolder%\hdd.txt
Run, %comspec% /c &quot;&quot;DISKPART.exe&quot; &quot;/s&quot; &quot;%watchfolder%\hdd.txt&quot; &gt; &quot;%watchfolder%\volumes.txt&quot;&quot;
WinWaitClose, ahk_class ConsoleWindowClass
sleep 1000

; получаем букву диска в переменную var
; Loop, read, %watchfolder%\volumes.txt

FileAppend, select volume %var%`nremove all dismount`nexit, %watchfolder%\hdd1.txt
Run, %comspec% /c &quot;&quot;DISKPART.exe&quot; &quot;/s&quot; &quot;%watchfolder%\hdd.txt&quot;&quot;
WinWaitClose, ahk_class ConsoleWindowClass
msgbox, DONE</code></pre></div><p>Но никак не получается распарсить инфу с CMD.<br />Помогите, пожалуйста, вытащить номер volume первого диска с лейблом Backup.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Wed, 19 Jun 2013 09:10:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73091#p73091</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=73062#p73062</link>
			<description><![CDATA[<p>Не подходят эти варианты - не вытаскивается.<br />Единственный рабочий вариант нашел:</p><p>&nbsp; &nbsp; Type <strong>diskpart</strong> and wait for the diskpart prompt (DISKPART&gt;)</p><p>&nbsp; &nbsp; Type<strong> list volume</strong></p><p>&nbsp; &nbsp; Note the volume number of the USB drive carefully (use listed properties such as drive letter, label, type and size for help)</p><p>&nbsp; &nbsp; Type <strong>select volume &lt;number&gt;</strong>, where &lt;number&gt; is the volume number noted above</p><p>&nbsp; &nbsp; Type <strong>remove all dismount</strong></p><p>&nbsp; &nbsp; Type <strong>exit</strong> to quit Diskpart</p><p>&nbsp; &nbsp;Now you should be able to safely remove your USB drive without fear of data loss.</p><p>Как мне это все забабахать через autohotkey, зная лейбл диска?<br />Пока написал вот это<br /></p><div class="codebox"><pre><code>Run, %comspec% /c DISKPART.exe /s C:hdd.txt &gt; C:volumes.txt</code></pre></div><p>а в hdd.txt<br /></p><div class="codebox"><pre><code>list volume</code></pre></div><p>На выходе получаем</p><p>Microsoft DiskPart version 6.1.7601<br />Copyright (C) 1999-2008 Microsoft Corporation.<br />On computer: TV-PC</p><div class="quotebox"><blockquote><p>Volume ###&nbsp; Ltr&nbsp; Label&nbsp; &nbsp; &nbsp; &nbsp; Fs&nbsp; &nbsp; &nbsp;Type&nbsp; &nbsp; &nbsp; &nbsp; Size&nbsp; &nbsp; &nbsp;Status&nbsp; &nbsp; &nbsp;Info<br />&nbsp; ----------&nbsp; ---&nbsp; -----------&nbsp; -----&nbsp; ----------&nbsp; -------&nbsp; ---------&nbsp; --------<br />&nbsp; Volume 0&nbsp; &nbsp; &nbsp;X&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DVD-ROM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 B&nbsp; No Media&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; Volume 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System Rese&nbsp; NTFS&nbsp; &nbsp;Partition&nbsp; &nbsp; 100 MB&nbsp; Healthy&nbsp; &nbsp; System&nbsp; <br />&nbsp; Volume 2&nbsp; &nbsp; &nbsp;C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NTFS&nbsp; &nbsp;Partition&nbsp; &nbsp; 465 GB&nbsp; Healthy&nbsp; &nbsp; Boot&nbsp; &nbsp; <br />&nbsp; Volume 3&nbsp; &nbsp; &nbsp;D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NTFS&nbsp; &nbsp;Partition&nbsp; &nbsp; 931 GB&nbsp; Healthy&nbsp; &nbsp; Pagefile<br />&nbsp; Volume 4&nbsp; &nbsp; &nbsp;G&nbsp; &nbsp;Backup&nbsp; &nbsp; &nbsp; &nbsp;NTFS&nbsp; &nbsp;Partition&nbsp; &nbsp;2794 GB&nbsp; Healthy&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; Volume 5&nbsp; &nbsp; &nbsp;F&nbsp; &nbsp;Backup&nbsp; &nbsp; &nbsp; &nbsp;NTFS&nbsp; &nbsp;Partition&nbsp; &nbsp;2794 GB&nbsp; Healthy&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; Volume 6&nbsp; &nbsp; &nbsp;Z&nbsp; &nbsp;Usb&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Partition&nbsp; &nbsp;2794 GB&nbsp; Healthy</p></blockquote></div><br /><p>По идее, чтобы узнать номер диска надо обрабатывать volumes.txt<br />А обрабатывать его тогда надо в hdd.txt?<br />Как-то все непонятно.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Tue, 18 Jun 2013 20:08:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=73062#p73062</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71707#p71707</link>
			<description><![CDATA[<p>Вот тут из-за этой битности у меня код teadrinker не срабатывал.<br /><a href="http://forum.script-coding.com/viewtopic.php?id=6093&amp;p=3">http://forum.script-coding.com/viewtopi … 93&amp;p=3</a></p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sun, 28 Apr 2013 00:22:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71707#p71707</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71704#p71704</link>
			<description><![CDATA[<p>Коды с autohotkey.com у меня тоже не работают.<br />Код из справки я проверил, во время копирования он не извлекает девайс, значит это безопасное извлечение, наверное.</p><p>Давно хотел у кого нибудь спросить, а зачем вообще использовать ахк 64 бит?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 27 Apr 2013 23:39:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71704#p71704</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71703#p71703</link>
			<description><![CDATA[<p>А у меня код из справки не работает, может потому, что ахк 64 бит.<br />Аналогично&nbsp; gAHK32&nbsp; тоже не работает.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 27 Apr 2013 23:27:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71703#p71703</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71701#p71701</link>
			<description><![CDATA[<p>У меня код из справки работает:<br /></p><div class="codebox"><pre><code>Driveletter = G:  ; Set this to the drive letter you wish to eject.

hVolume := DllCall(&quot;CreateFile&quot;
    , Str, &quot;\\.\&quot; . Driveletter
    , UInt, 0x80000000 | 0x40000000  ; GENERIC_READ | GENERIC_WRITE
    , UInt, 0x1 | 0x2  ; FILE_SHARE_READ | FILE_SHARE_WRITE
    , UInt, 0
    , UInt, 0x3  ; OPEN_EXISTING
    , UInt, 0, UInt, 0)
if hVolume &lt;&gt; -1
{
    DllCall(&quot;DeviceIoControl&quot;
        , UInt, hVolume
        , UInt, 0x2D4808   ; IOCTL_STORAGE_EJECT_MEDIA
        , UInt, 0, UInt, 0, UInt, 0, UInt, 0
        , UIntP, dwBytesReturned  ; Unused.
        , UInt, 0)
    DllCall(&quot;CloseHandle&quot;, UInt, hVolume)
} </code></pre></div><p>правда я не знаю безопасное ли это извлечение?</p><p>Ещё можно покурить:<br /><a href="http://www.autohotkey.com/board/topic/80486-solved-get-hardware-serial-no-of-usb-stick/?hl=cm_request_device_eject">http://www.autohotkey.com/board/topic/8 … vice_eject</a> </p><p><a href="http://www.autohotkey.com/board/topic/41310-safelyremoveums-safely-remove-usb-mass-storage-drives/?hl=cm_request_device_eject">http://www.autohotkey.com/board/topic/4 … vice_eject</a></p><p>ну и:<br /><a href="http://msdn.microsoft.com/en-us/library/windows/hardware/ff539806">http://msdn.microsoft.com/en-us/library … e/ff539806</a></p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 27 Apr 2013 19:00:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71701#p71701</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71700#p71700</link>
			<description><![CDATA[<p>Речь про USB диск, который хочутся отключить после бекапа.<br />У диска постоянная буква.</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 27 Apr 2013 18:01:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71700#p71700</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71699#p71699</link>
			<description><![CDATA[<p>То есть просто путь? Речь только про флэшки?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 27 Apr 2013 17:52:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71699#p71699</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71698#p71698</link>
			<description><![CDATA[<p>Проклятая невнимательность <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /><br /></p><div class="quotebox"><blockquote><p>А в принципе, как указывать устройство для извлечения?</p></blockquote></div><p>В скрипте по ссылке очень удобно.<br />Нужно лишь вписать в скрипт<br /></p><div class="codebox"><pre><code>RemUMS D:\ </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Sat, 27 Apr 2013 17:50:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71698#p71698</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Безопасно вытащить USB]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=71696#p71696</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Бузопасно вытащить USB</p></blockquote></div><p>Я бы сменил на:<br /></p><div class="quotebox"><blockquote><p>AHK: Безопасно вытащить USB</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sat, 27 Apr 2013 17:36:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=71696#p71696</guid>
		</item>
	</channel>
</rss>
