<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; Автоматический запуск 1С через VBScript]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=5509</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5509&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Автоматический запуск 1С через VBScript».]]></description>
		<lastBuildDate>Sun, 13 Feb 2011 19:44:05 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45124#p45124</link>
			<description><![CDATA[<div class="quotebox"><cite>The_Immortal пишет:</cite><blockquote><p><strong>alexii</strong>, Почему-то ваш код мне в любом случае выдает &quot;Process started fail&quot;...</p></blockquote></div><p><strong>The_Immortal</strong>, у меня работает:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objSWbemServicesEx
Dim intProcessID

Set objSWbemServicesEx = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)

If objSWbemServicesEx.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;1cv7s.exe&#039;&quot;).Count = 0 Then
    If objSWbemServicesEx.Get(&quot;Win32_Process&quot;).Create( _
        &quot;&quot;&quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot;&quot; enterprise /dE:\Песочница\Buch\1SBDB /nAdm /p1&quot;, _
        &quot;E:\Песочница\Buch\1SBDB&quot;, Null, intProcessID) = 0 Then
        
        WScript.Echo &quot;Process started successfully. PID: &quot;, intProcessID
    Else
        WScript.Echo &quot;Process started fail&quot;
    End If
End If

WScript.Quit 0</code></pre></div><div class="quotebox"><blockquote><div class="codebox"><pre><code>Process started successfully. PID:  1992</code></pre></div></blockquote></div><p>Смотрите правильность и существование путей.</p><div class="quotebox"><cite>The_Immortal пишет:</cite><blockquote><p>Ребят, а не подскажите плиз, как записывать инфу файл?</p></blockquote></div><p><span style="color: Green">Один вопрос — одна тема: <a href="http://forum.script-coding.com/rules.html#3.11.">§3.11</a>.</span></p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Sun, 13 Feb 2011 19:44:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45124#p45124</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45105#p45105</link>
			<description><![CDATA[<p>Все, я болван. Надо вообще файл открывать на добавление, а я его заново создаю =/<br />Подскажите, пожалуйста, как одной строкой вот это можно оформить?<br /></p><div class="codebox"><pre><code>    tf.Write(time)
    tf.WriteLine(&quot; Не удалось запустить процесс.&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The_Immortal)]]></author>
			<pubDate>Sun, 13 Feb 2011 12:47:04 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45105#p45105</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45104#p45104</link>
			<description><![CDATA[<p>Ребят, а не подскажите плиз, как записывать инфу файл? Мне надо каждый раз, когда не удалось запустить процесс писать в файл след. инфу:<br />Время: Не удалось запустить файл.</p><p>Ну как получать текущее время и дату, я надеюсь что найду <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Проблема с записью файл:</p><div class="codebox"><pre><code>Dim fso, tf
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set tf = fso.CreateTextFile(&quot;c:\testfile.txt&quot;, True)

...

Else    
    WScript.Echo &quot;Process started fail&quot;
    tf.WriteLine(&quot;Не удалось запустить процесс.&quot;)
    tf.Close
        WScript.Quit 0</code></pre></div><p>Таким образом файл каждый раз обновляется, а мне надо, чтобы строчки добавлялись (лог все-таки).</p>]]></description>
			<author><![CDATA[null@example.com (The_Immortal)]]></author>
			<pubDate>Sun, 13 Feb 2011 11:26:55 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45104#p45104</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45103#p45103</link>
			<description><![CDATA[<p><strong>alexii</strong>, <strong>VSVLAD</strong> - Спасибо большое, ребят! Буду знать! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p><strong>alexii</strong>, Почему-то ваш код мне в любом случае выдает &quot;Process started fail&quot;... Но я сделал по примитивному:</p><br /><div class="codebox"><pre><code>Set WshShell = Wscript.CreateObject(&quot;Wscript.Shell&quot;)
CmdLine = &quot;&quot;&quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot;&quot; enterprise /DG:\db\1C_SQL\ /N Adm /P 1&quot;
CmdLine2 = &quot;ping.exe -n 20 127.0.0.1&quot;

Dim objSWbemServicesEx
Dim intProcessID


Set objSWbemServicesEx = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)

If objSWbemServicesEx.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;1cv7s.exe&#039;&quot;).Count = 0 Then
        WshShell.Run CmdLine, 1, False
    WScript.Sleep 3000
        WshShell.Run CmdLine2, 1, True
Else    
        WScript.Quit 0
      
End If

WScript.Quit 0</code></pre></div><p>Вот так вроде работает <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Огромное спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (The_Immortal)]]></author>
			<pubDate>Sun, 13 Feb 2011 11:12:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45103#p45103</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45094#p45094</link>
			<description><![CDATA[<p>Ещё как примеры:</p><div class="codebox"><pre><code>1)    MsgBox &quot;&quot;&quot;В кавычках&quot;&quot; сообщение&quot;
2)    MsgBox &quot;&quot;&quot;&quot; &amp; &quot;В кавычках&quot; &amp; &quot;&quot;&quot;&quot; &amp; &quot; сообщение&quot;
3)    MsgBox Chr(34) &amp; &quot;В кавычках&quot; &amp; Chr(34) &amp; &quot; сообщение&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (VSVLAD)]]></author>
			<pubDate>Sun, 13 Feb 2011 08:28:35 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45094#p45094</guid>
		</item>
		<item>
			<title><![CDATA[Re: Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45086#p45086</link>
			<description><![CDATA[<p>Внутренние кавычки удваиваются:«… = &quot;<span style="color: red"><strong>&quot;&quot;</strong></span>C:\Program Files\1Cv77\BIN\1cv7s.exe<span style="color: red"><strong>&quot;&quot;</strong></span> enterprise /DG:\db\1C_SQL\ /N Adm /P 1&quot;»<br />Попробуйте так:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objSWbemServicesEx
Dim intProcessID

Set objSWbemServicesEx = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)

If objSWbemServicesEx.ExecQuery(&quot;SELECT * FROM Win32_Process WHERE Name = &#039;1cv7s.exe&#039;&quot;).Count = 0 Then
    If objSWbemServicesEx.Get(&quot;Win32_Process&quot;).Create( _
        &quot;&quot;&quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot;&quot; enterprise /DG:\db\1C_SQL\ /N Adm /P 1&quot;, _
        &quot;G:\db\1C_SQL&quot;, Null, intProcessID) = 0 Then
        
        WScript.Echo &quot;Process started successfully. PID: &quot;, intProcessID
    Else
        WScript.Echo &quot;Process started fail&quot;
    End If
End If

WScript.Quit 0</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Sun, 13 Feb 2011 00:59:52 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45086#p45086</guid>
		</item>
		<item>
			<title><![CDATA[Автоматический запуск 1С через VBScript]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=45083#p45083</link>
			<description><![CDATA[<p>Ребят, всех приветствую!<br />В общем, у меня следующая задача: проверять запущена ли процесс 1cv7s.exe и если нет, то запускать 1С, а следом еще одну утилитку.<br />Решил реализовать ее на VBScript (как/где еще это можно сделать - не знаю - может кто подскажет варианты).<br />Как проверять процесс не знаю (может тоже подскажите?)... Пока пробую автоматически запуск 1С... В скрипте наткнулся на следующую проблему:<br /></p><div class="codebox"><pre><code>Set WshShell = Wscript.CreateObject(&quot;Wscript.Shell&quot;)
CmdLine = &quot;&quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot; enterprise /DG:\db\1C_SQL\ /N Adm /P 1&quot;
WshShell.Run CmdLine, 1, True</code></pre></div><p>Не может выполнить вторую строчку из-за кавычек... Структура задания переменной такая: var = &quot;...&quot; А у меня в описании самой переменной уже есть кавычки: &quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot;<br />Как быть не знаю... :(smile:(<br />Также пробовал такие варианты:<br /></p><div class="codebox"><pre><code>CmdLine = &quot;&quot;&quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot; enterprise /DG:\db\1C_SQL\ /N Adm /P 1&quot;&quot;</code></pre></div><div class="codebox"><pre><code>CmdLine = Chr(34)&amp; &quot;C:\Program Files\1Cv77\BIN\1cv7s.exe&quot; enterprise /DG:\db\1C_SQL\ /N Adm /P 1 &amp;Chr(34)</code></pre></div><p>Не помогло. По-прежнему пишет: &quot;Предполагается наличие окончания инструкции&quot;</p><p>Подскажите, пожалуйста...<br />Ну или может решение есть какое-нибудь другое... </p><p>Буду очень признателен!</p>]]></description>
			<author><![CDATA[null@example.com (The_Immortal)]]></author>
			<pubDate>Sat, 12 Feb 2011 22:18:45 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=45083#p45083</guid>
		</item>
	</channel>
</rss>
