<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; WSH: Ошибка выполнения команды через WSH.Run()]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8450&amp;type=atom" />
	<updated>2013-07-05T19:48:57Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8450</id>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Ошибка выполнения команды через WSH.Run()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73516#p73516" />
			<content type="html"><![CDATA[<p>Для метода «.Exec()» не предусмотрено механизма управления видимостью окна дочернего процесса.</p><p>Если очень надо скрывать — делайте что-то наподобие: «.Run(&quot;&quot;&quot;%comspec%&quot;&quot; /c &quot;&quot;%ProgramFiles%\ImageMagick-6.3.4-Q8\identify.exe&quot;&quot; &quot;&quot;C:\4544564533_fa2ceb7ffb_o.jpg&quot;&quot; &gt;&quot;&quot;%Temp%\MyIdentify.tmp&quot;&quot;&quot;, 0, True)», затем разбирайте полученный файл.</p><p>Вы так и не написали — что именно Вы хотите получить: размеры, битность, або что ещё?</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2013-07-05T19:48:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73516#p73516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Ошибка выполнения команды через WSH.Run()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73513#p73513" />
			<content type="html"><![CDATA[<p>Спасибо, alexii! Получилось! Единственный минус, во время работы все равно мелькает DOS-окно. Нельзя этого никак избежать?</p>]]></content>
			<author>
				<name><![CDATA[ae23]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30369</uri>
			</author>
			<updated>2013-07-05T11:17:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73513#p73513</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Ошибка выполнения команды через WSH.Run()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73512#p73512" />
			<content type="html"><![CDATA[<p>Да, я именно хочу получить результат работы утилиты. Спасибо, alexii, сейчас попробую воспользоваться Вашим кодом</p>]]></content>
			<author>
				<name><![CDATA[ae23]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30369</uri>
			</author>
			<updated>2013-07-05T11:10:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73512#p73512</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: WSH: Ошибка выполнения команды через WSH.Run()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73511#p73511" />
			<content type="html"><![CDATA[<p><strong>ae23</strong>, Вы путаете «.Run()» и «.Exec()». Вы вообще что хотите получить — вывод утилиты?</p><p>У меня нет v8.x. На v7.7 работает, например, такое:<br /></p><div class="codebox"><pre><code>Процедура Сформировать()
    Перем WshRunning;
    Перем WshFinished;
    Перем WshFailed;

    Перем objWshShell;
    Перем objWshExec;
    Перем strStdOut;
    
    
    WshRunning  = 0;
    WshFinished = 1;
    WshFailed   = 2;
    
    objWshShell = СоздатьОбъект(&quot;WScript.Shell&quot;);
    objWshExec  = objWshShell.Exec(&quot;&quot;&quot;C:\Program Files\ImageMagick-6.3.4-Q8\identify.exe&quot;&quot; &quot;&quot;C:\4544564533_fa2ceb7ffb_o.jpg&quot;&quot;&quot;);
    
    Если objWshExec.Status &lt;&gt; WshFailed Тогда
        strStdOut = &quot;&quot;;
        
        Пока objWshExec.Status = WshRunning Цикл
            strStdOut = strStdOut + objWshExec.StdOut.ReadAll();
        КонецЦикла;
    КонецЕсли;

    Сообщить(strStdOut);
КонецПроцедуры
</code></pre></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Результат</div><div class="fancy_spoiler"><div class="codebox"><pre><code>C:\4544564533_fa2ceb7ffb_o.jpg JPEG 4752x3168 4752x3168+0+0 DirectClass 8-bit 8.40572mb 0.969u 0:01</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2013-07-05T11:06:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73511#p73511</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[WSH: Ошибка выполнения команды через WSH.Run()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=73507#p73507" />
			<content type="html"><![CDATA[<p>Выполняю в DOS-окне такую команду:<br /><strong>C:\Progra~1\ImageM~1.6-Q\Identify.exe D:\test\003.jpg</strong><br />, которая возвращает нужный мне результат:<br /><em>D:\test\003.jpg JPEG 3000x4000 3000x4000+0+0 8-bit sRGB 3.757MB 0.000u 0:00.021</em></p><p>Теперь хочу такую же команду выполнить в 1с и получить результат для дальнейшего анализа его текста. Мне не нужно, чтобы открывалось и закрывалось окно DOS, поэтому в 1с запускаю такой код:<br /><strong>WshShell = новый ComОбъект(&quot;WScript.Shell&quot;);<br />RetCode = WshShell.Run(&quot;C:\Progra~1\ImageM~1.6-Q\Identify.exe D:\test\003.jpg&quot;,0,Истина).StdOut;<br />Сообщить(RetCode);<br /></strong><br />В результате выполнения сообщается: <br /><em>Ошибка выполнения команды C:\Progra~1\ImageM~1.6-Q\Identify.exe D:\test\003.jpg</em></p><p>Что я делаю не так, как получить такую же строку-результат, как и в DOS-окне?</p>]]></content>
			<author>
				<name><![CDATA[ae23]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30369</uri>
			</author>
			<updated>2013-07-05T10:24:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=73507#p73507</id>
		</entry>
</feed>
