<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: получение списка открытых файлов на файл-сервере]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=787&amp;type=atom" />
	<updated>2007-10-26T11:20:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=787</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: получение списка открытых файлов на файл-сервере]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=5695#p5695" />
			<content type="html"><![CDATA[<p>Запись информации об открытых файлах и сессиях на сервере в базу данных FireBird. Скрипт запускается на сервере, обновление информации происходит каждые 10 секунд. Для функционирования, естественно, надо поставить сам сервер FireBird 1.5 и ODBC драйвер для базы данных Firebird, Firebird_ODBC_2.0.0-Win32.exe (можно легко найти в инете в свободном доступе).<br /></p><div class="codebox"><pre><code>On Error Resume Next
ServerName = &quot;.&quot;

While 1 &#039;Вечный цикл
    Set objConn = CreateObject(&quot;ADODB.Connection&quot;)
    objConn.ConnectionString = &quot;Driver=Firebird/InterBase(r) driver;Uid=SYSDBA;Pwd=masterkey;DbName=hostname:путь к вашей БД;&quot;
    objConn.ConnectionTimeOut = 15
    objConn.CommandTimeout = 30
    objConn.Open

    Set objRecordset = objConn.Execute(&quot;DELETE FROM OPENFILES;&quot;)
    Set objRecordset = objConn.Execute(&quot;DELETE FROM USERS;&quot;)
    &#039;==============================================================================
    Set FileService = GetObject(&quot;WinNT://&quot; &amp;  ServerName &amp; &quot;/LanmanServer&quot;)

    For Each Res In FileService.Resources    
        Set objRecordset = objConn.Execute(&quot;INSERT INTO OPENFILES (NAME_USER, NAME_FILE) VALUES (&#039;&quot;&amp; Res.Get(&quot;User&quot;) &amp;&quot;&#039;,&#039;&quot;&amp; Res.Get(&quot;Path&quot;) &amp;&quot;&#039;)&quot;)
    Next

    Set objConnection = GetObject(&quot;WinNT://&quot; &amp; ServerName &amp;&quot;/LanmanServer&quot;)
    Set colSessions = objConnection.Sessions

    For Each objSession in colSessions
        Set objRecordset = objConn.Execute(&quot;INSERT INTO USERS (NAME_USER, NAME_COMPUTER) VALUES (&#039;&quot;&amp; objSession.User &amp;&quot;&#039;,&#039;&quot;&amp; objSession.Computer &amp;&quot;&#039;)&quot;)
    Next

    objConn.Close

    WScript.Sleep 10000
Wend</code></pre></div><p>БД содержится в прикреплённом файле.<br />Автор скрипта - <strong>JordanS</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2007-10-26T11:20:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=5695#p5695</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: получение списка открытых файлов на файл-сервере]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=5640#p5640" />
			<content type="html"><![CDATA[<p>Скрипт выводит список открытых по сети файлов на файл-сервере и имена пользователей домена, открывших эти файлы.<br /></p><div class="codebox"><pre><code>ServerName = &quot;ComputerName&quot;
&#039;==============================================================================
On Error Resume Next
Set FileService = GetObject(&quot;WinNT://&quot; &amp; ServerName &amp; &quot;/LanmanServer&quot;)
For Each Res In FileService.Resources
    WScript.Echo Res.Get(&quot;User&quot;) &amp; &quot; &quot; &amp; Res.Get(&quot;Path&quot;)
    WScript.Echo
Next</code></pre></div><p>В качестве ServerName можно использовать &quot;.&quot; (текущий компьютер).</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2007-10-24T14:07:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=5640#p5640</id>
		</entry>
</feed>
