<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Удаление в файлов корзину]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6606&amp;type=atom" />
	<updated>2011-12-28T06:37:59Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6606</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55059#p55059" />
			<content type="html"><![CDATA[<p>Вспомнил еще один пример асинхронной работы методов Shell.Application с которым столкнулся ранее в процессе поиска решения задачи архивирования файлов:<br /></p><div class="codebox"><pre><code>
sZipFolderPath = &quot;c:\temp&quot; &#039;каталог для zip-архивов

With CreateObject(&quot;Scripting.FileSystemObject&quot;)
	&#039;путь к текущему каталогу
	sFolderPath = .GetParentFolderName(WScript.ScriptFullName)
	&#039;путь к zip-архиву
	sZipPath = sZipFolderPath &amp; &quot;\&quot; &amp; .GetBaseName(sFolderPath) &amp; &quot;.zip&quot;
	&#039;создаем пустой zip-файл
	.CreateTextFile(sZipPath, True).Write &quot;PK&quot; &amp; Chr(5) &amp; Chr(6) &amp; String(18, vbNullChar)
End With
&#039;копируем файлы в архив
With CreateObject(&quot;Shell.Application&quot;)
	.NameSpace(sZipPath).CopyHere .NameSpace(sFolderPath).Items
End With
&#039;без Sleep - никак, если размер каталога большой - добавляем секунд
WScript.Sleep 1000</code></pre></div>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-12-28T06:37:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55059#p55059</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55038#p55038" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexii пишет:</cite><blockquote><p><strong>VSVLAD</strong>, <strong>dab00</strong> — так синхронно или асинхронно происходит?</p></blockquote></div><p>Похоже асинхронно. Я сразу обозначил, что &quot;для кого-то очевидно...&quot;, <strong>alexii</strong> как всегда на высоте <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" />.<br />Видимо, как отмечено в <a href="http://forum.script-coding.com/viewtopic.php?id=982">посте</a>, &quot;скрипт завершает свою работу, прежде чем методы успевают отработать&quot;.<br /></p><div class="quotebox"><cite>smaharbA пишет:</cite><blockquote><p>дануна</p></blockquote></div><p>Это не наш метод <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-12-27T17:58:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55038#p55038</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55036#p55036" />
			<content type="html"><![CDATA[<p>дануна</p><p>del /q %temp%\r.txt &amp; fsutil file createnew %temp%\r.txt 1000000000 &amp; start &quot;&quot; mshta &quot;javascript:x=new ActiveXObject(&#039;shell.application&#039;).NameSpace(&#039;::{645FF040-5081-101B-9F08-00AA002F954E}&#039;);x.MoveHere(&#039;%temp:\=/%/r.txt&#039;);window.close()&quot; &amp; dir %temp%\r.txt</p>]]></content>
			<author>
				<name><![CDATA[smaharbA]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2911</uri>
			</author>
			<updated>2011-12-27T17:04:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55036#p55036</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55033#p55033" />
			<content type="html"><![CDATA[<p>Проверил также в VBS, запускал без флагов... Заменил Sleep на MsgBox. Пока я не отменил перемещение, MsgBox не вылез, следовательно синхронно.</p>]]></content>
			<author>
				<name><![CDATA[VSVLAD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24998</uri>
			</author>
			<updated>2011-12-27T16:18:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55033#p55033</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55032#p55032" />
			<content type="html"><![CDATA[<p>в вб работают флаги, в вбс нет</p>]]></content>
			<author>
				<name><![CDATA[smaharbA]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2911</uri>
			</author>
			<updated>2011-12-27T16:13:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55032#p55032</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55031#p55031" />
			<content type="html"><![CDATA[<p>синхронно, я проверил у себя. Запускал в среде VB6/WScript XP SP3. Появляется стандартное окошко пермещения файла, которое показывает Explorer</p>]]></content>
			<author>
				<name><![CDATA[VSVLAD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24998</uri>
			</author>
			<updated>2011-12-27T16:07:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55031#p55031</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55030#p55030" />
			<content type="html"><![CDATA[<p><strong>VSVLAD</strong>, <strong>dab00</strong> — так синхронно или асинхронно происходит?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-27T15:43:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55030#p55030</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55029#p55029" />
			<content type="html"><![CDATA[<p><strong>2VSVLAD</strong>: для <em>перемещения</em> неважно, большой файл или мелкий.</p><div class="quotebox"><cite>dab00 пишет:</cite><blockquote><p>…и заметил одну особенность.</p></blockquote></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=982">VBScript: запуск файлов ассоциированным приложением</a></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2011-12-27T15:35:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55029#p55029</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55027#p55027" />
			<content type="html"><![CDATA[<p>Читать количество файлов в исходной папке, если уменьшилось - то перемещение завершено успешно и продолжать дальше по циклу For Each. Sleep 10 не хватит если файл большой.</p><p>--<br />В принципе можно и не читать, операция происходит синхронно, поэтому код приостановит своё выполнение пока файл не переместится</p>]]></content>
			<author>
				<name><![CDATA[VSVLAD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24998</uri>
			</author>
			<updated>2011-12-27T15:30:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55027#p55027</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55024#p55024" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>smaharbA пишет:</cite><blockquote><p>фишка не в слипе, читай содержимое корзины</p></blockquote></div><p>Не могли бы Вы пояснить, зачем и куда читать?&nbsp; Со слипом прокатило...</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-12-27T13:11:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55024#p55024</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55021#p55021" />
			<content type="html"><![CDATA[<p>фишка не в слипе, читай содержимое корзины</p>]]></content>
			<author>
				<name><![CDATA[smaharbA]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2911</uri>
			</author>
			<updated>2011-12-27T12:13:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55021#p55021</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Удаление в файлов корзину]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=55020#p55020" />
			<content type="html"><![CDATA[<p>Здравствуйте, уважаемые коллеги.<br />Сегодня решал задачу удаления файлов в корзину через VBS и заметил одну особенность. Потратил чуть больше времени, чем ожидал, надеюсь решение сэкономит ваше. <br />Фишка в WScript.Sleep. Без него никак. Наверное для кого-то очевидно... короче вот:<br /></p><div class="codebox"><pre><code>
sFolderPath = &quot;c:\temp\&quot;
dDateDif = DateAdd(&quot;d&quot;, -7, Date)
sExt = &quot;txt&quot;

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set recyclebin = CreateObject(&quot;Shell.Application&quot;).Namespace(10)

For Each oFile In fso.GetFolder(sFolderPath).Files
	If oFile.DateLastModified &lt; dDateDif And LCase(fso.GetExtensionName(oFile.Name)) = LCase(sExt) Then			
		recyclebin.MoveHere(oFile.Path)
		WScript.Sleep 10 
	End If
Next</code></pre></div><p>Вероятно в случае большого размера файлов количество миллисекунд надо будет увеличить.</p>]]></content>
			<author>
				<name><![CDATA[dab00]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27085</uri>
			</author>
			<updated>2011-12-27T11:48:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=55020#p55020</id>
		</entry>
</feed>
