<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBScript:Выборка строки из текста или как распарсить переменную?]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=7274</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7274&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBScript:Выборка строки из текста или как распарсить переменную?».]]></description>
		<lastBuildDate>Tue, 12 Jun 2012 04:44:32 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBScript:Выборка строки из текста или как распарсить переменную?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=60888#p60888</link>
			<description><![CDATA[<p>Как-то так:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objFSO
Dim objWshShell

Dim objSWbemLocator
Dim objSWbemServicesEx
Dim collSWbemObjectSet
Dim objSWbemObjectEx

Dim strArguments

If MsgBox(&quot;Создать на Рабочем столе модифицированный ярлык для запуска игры «Heroes of Newerth» без «Garena»?&quot; &amp; vbCrLf &amp; vbCrLf &amp; _
    &quot;Для создания модифицированного ярлыка нажмите «OK» и затем запустите игру «Heroes of Newerth»&quot;, _
    vbOKCancel + vbQuestion, &quot;Создание модифицированного ярлыка&quot;) = vbOK Then
    
    Set objFSO             = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    Set objWshShell        = WScript.CreateObject(&quot;WScript.Shell&quot;)
    
    Set objSWbemLocator    = WScript.CreateObject(&quot;WbemScripting.SWbemLocator&quot;)
    Set objSWbemServicesEx = objSWbemLocator.ConnectServer(&quot;.&quot;, &quot;root\cimv2&quot;)
    Set collSWbemObjectSet = objSWbemServicesEx.ExecNotificationQuery( _
        &quot;SELECT * FROM __InstanceCreationEvent WITHIN 1 &quot; &amp; _
        &quot;WHERE TargetInstance ISA &#039;Win32_Process&#039; AND TargetInstance.Name = &#039;hon.exe&#039;&quot; _
        )
    
    Set objSWbemObjectEx = collSWbemObjectSet.NextEvent.TargetInstance
    
    With WScript.CreateObject(&quot;VBScript.RegExp&quot;)
        .Pattern = &quot;^(\s*&quot;&quot;?&quot; &amp; Replace(Replace(objSWbemObjectEx.ExecutablePath, &quot;\&quot;, &quot;\\&quot;), &quot;.&quot;, &quot;\.&quot;) &amp; &quot;&quot;&quot;?\s*)(.*)$&quot;
        strArguments = .Replace(objSWbemObjectEx.CommandLine, &quot;$2&quot;)
    End With
    
    With objWshShell
        With .CreateShortcut(.SpecialFolders(&quot;Desktop&quot;) &amp; &quot;\Heroes of Newerth Modified.lnk&quot;)
            .TargetPath       = &quot;&quot;&quot;&quot; &amp; objSWbemObjectEx.ExecutablePath &amp; &quot;&quot;&quot;&quot;
            .WindowStyle      = 1
            .IconLocation     = objSWbemObjectEx.ExecutablePath &amp; &quot;,0&quot;
            .Arguments        = strArguments
            .Description      = &quot;Heroes of Newerth Modified&quot;
            .WorkingDirectory = objFSO.GetParentFolderName(objSWbemObjectEx.ExecutablePath)
            
            .Save
        End With
    End With
    
    Set objSWbemObjectEx   = Nothing
    Set collSWbemObjectSet = Nothing
    Set objSWbemServicesEx = Nothing
    Set objSWbemLocator    = Nothing
    
    Set objWshShell        = Nothing
    Set objFSO             = Nothing
    
    MsgBox &quot;Для запуска игры без «Garena», запустите ярлык [Heroes of Newerth Modified] с Рабочего стола&quot;, vbOKOnly + vbInformation, &quot;Ярлык создан&quot;
End If

WScript.Quit 0</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Tue, 12 Jun 2012 04:44:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=60888#p60888</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBScript:Выборка строки из текста или как распарсить переменную?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=60881#p60881</link>
			<description><![CDATA[<p>Нашел такой вариант решения проблемы.<br /></p><div class="codebox"><pre><code>strX = &quot;C:\Games\HoN_GGC\Apps\HoNCIS\hon.exe -keyxxxxxxxxxxxxxxxx -masterserver masterserver.cis.s2games.com -webserver cis.heroesofnewerth.com -region RU&quot;
intPoz1 = InStr(1, strX, &quot;-key&quot;, vbTextCompare)
msgbox initPoz1
intPoz2 = InStr(intPoz1+1, strX, &quot;RU&quot;, vbTextCompare)
msgbox initPoz2
strY = Mid(strX, intPoz1, intPoz2 - intPoz1 - 1)
msgbox strY</code></pre></div><p>Хотелось бы конечно посмотреть как будет выглядеть через объект RegExp.</p>]]></description>
			<author><![CDATA[null@example.com (Xenon)]]></author>
			<pubDate>Mon, 11 Jun 2012 19:57:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=60881#p60881</guid>
		</item>
		<item>
			<title><![CDATA[VBScript:Выборка строки из текста или как распарсить переменную?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=60878#p60878</link>
			<description><![CDATA[<p>Здравствуйте. Помощь нужна с ниже приведенным скриптом. Скрипт вынимает параметры запуска процесса через WMIC и создает ярлык для запущенного процесса на рабочем столе. Не знаю как вытащить отдельно аргументы запуска из переменной взятой из WMIC.</p><div class="codebox"><pre><code>
Dim sIc
Dim sIp
Dim sMessaga
Dim MyProc
&#039;Цикл проверки доступности процесса и изъятия командной строки
Do
Set Processes = GetObject(&quot;winmgmts://localhost&quot;)
Set MyProcEnum = Processes.ExecQuery(&quot;select * from Win32_Process where Name = &#039;hon.exe&#039;&quot;)
MyProc = False
For Each Item In myProcEnum
If Item.Name = &quot;hon.exe&quot; Then
MyProc = True
sIc = Item.CommandLine
sIp = Item.ExecutablePath
End If
Next
&#039;Сообщение об отсутствии процесса
If Not myProc Then
sMessaga = MsgBox (&quot;Игра не запущена!&quot; &amp; vbcrlf &amp; &quot;Запустите игру и нажмите ОК&quot;, 49, &quot;Ошибка&quot;)
If sMessaga = vbCancel then
Wscript.quit
End If
End If
WScript.Sleep 10000
Loop Until MyProc = True
&#039;Создание ярлыка на десктопе
set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot; )
strDesktop = WshShell.SpecialFolders(&quot;Desktop&quot; )
set oShellLink = WshShell.CreateShortcut(strDesktop &amp; &quot;\Heroes of Newert-прямой-.lnk&quot; )
Msgbox sIp
oShellLink.TargetPath = sIp
oShellLink.WindowStyle = 1
oShellLink.IconLocation = sIp
oShellLink.Arguments = sIc
oShellLink.Description = &quot;FaJIc()n&quot;
oShellLink.WorkingDirectory = sIp
oShellLink.Save
msgbox &quot;Ярлык создан&quot; &amp; vbcrlf &amp; &quot;Для запуска игры без гарены, запустите ярлык с рабочего стола с пометкой -прямой-&quot;, 64, &quot;Информация&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Xenon)]]></author>
			<pubDate>Mon, 11 Jun 2012 19:09:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=60878#p60878</guid>
		</item>
	</channel>
</rss>
