<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: Как скопировать в system32]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7363&amp;type=atom" />
	<updated>2012-07-24T04:45:33Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7363</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61944#p61944" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Set objShell = CreateObject(&quot;WScript.Shell&quot;)
Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objNetwork = CreateObject(&quot;Wscript.Network&quot;)
strFileName = &quot;C:\TestFile.txt&quot;
strFilesrvany = &quot;C:\srvany.exe&quot;

Set fOpenResults = oFSO.OpenTextFile(strFileName, 1) 
Do While fOpenResults.AtEndOfStream &lt;&gt; True
    sResult = fOpenResults.ReadLine
strDestFolder = &quot;\\sResult\C$\WINNT\System32\srvany.exe&quot;
strDestFolderW = &quot;\\sResult\C$\Windows\System32\srvany.exe&quot; - тут хотелось бы еще проверку устроить 
на предмет присутствия той или иной папки и в зависимости от наличия той или иной копировать в присутствующую

Wscript.Echo(sResult)
Set objScriptExec = objShell.Exec(&quot;%comspec% /c ping.exe -n 1 &quot; &amp; sResult)
    strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, &quot;ttl=&quot;) Then   
        WScript.Echo(sResult &amp; &quot;Комп в сети!!!&quot;)
    Else
     WScript.Echo(sResult &amp; &quot;: Не отвечает...&quot;)
    End If
Host = objNetwork.ComputerName 
set oWMISvc = GetObject(&quot;winmgmts:\\&quot; &amp; Host &amp; &quot;\root\cimv2&quot;)
oWMISvc.Security_.ImpersonationLevel = 4
set oFile = oWMISvc.Get(&quot;cim_datafile=&#039;&quot; &amp; strFilesrvany &amp; &quot;&#039;&quot;)
set oProcess = oWMISvc.Get(&quot;Win32_Process&quot;)
lRet = oFile.Copy(strDestFolder)
if lRet &lt;&gt; 0 then
wscript.Echo &quot;File Copy Failed Returned Code : &quot; &amp; lRet
end if

Loop
fOpenResults.Close</code></pre></div><p>говорит, что путь не найден - почему? <br />Почему я понял, теперь вопрос как подставить sResult в strDestFolder?<br />Вопрос отпал - сам разобрался</p>]]></content>
			<author>
				<name><![CDATA[Starley25]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25241</uri>
			</author>
			<updated>2012-07-24T04:45:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61944#p61944</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61823#p61823" />
			<content type="html"><![CDATA[<p>Ясно.</p><p>Примерно так:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim objFSO
Dim strSourceFile
Dim strDestFolder

Set objFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)

strSourceFile = &quot;c:\файл.exe&quot;
strDestFolder = &quot;\\Server\ADMIN$\System32&quot;

If objFSO.FileExists(strSourceFile) Then
    If objFSO.FolderExists(strDestFolder) Then
        objFSO.CopyFile strSourceFile, strDestFolder &amp; &quot;\&quot;, True
    Else
        WScript.Echo &quot;Destination folder [&quot; &amp; strDestFolder&amp; &quot;] not found&quot;
    End If
Else
    WScript.Echo &quot;Source file [&quot; &amp; strSourceFile &amp; &quot;] not found&quot;
End If

Set objFSO = Nothing

WScript.Quit 0</code></pre></div><p>«ADMIN$» — скрытый административный ресурс на удалённой машине «Server».</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-07-20T08:05:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61823#p61823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61813#p61813" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>strSourceFile = &quot;c:\файл.exe&quot;
strDestFolder = &quot;тут должно быть \\имя машины\WINNT\System32\файл.exe&quot;

objFSO.CopyFile strSourceFile, strDestFolder &amp; &quot;\&quot;, True</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Starley25]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25241</uri>
			</author>
			<updated>2012-07-20T00:32:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61813#p61813</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61712#p61712" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>Starley25</strong>, префикс пишется <strong>перед</strong> заголовком темы — посмотрите другие темы этого раздела форума. Я поправил Ваш пост.</span></p><div class="quotebox"><blockquote><p>и скопировать в папку С:\WINNT\System32\файл.exe</p></blockquote></div><p>«С:\WINNT\System32\файл.exe» — не папка, а файл. Уточните, что Вы хотите.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-07-18T08:34:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61712#p61712</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61674#p61674" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>Starley25</strong>, я для кого писал в <a href="http://forum.script-coding.com/viewtopic.php?id=7354">прошлой теме</a>:</span><br /></p><div class="quotebox"><blockquote><p><span style="color: Green">Укажите префикс языка в заголовке темы.</span></p></blockquote></div><div class="quotebox"><blockquote><p><span style="color: Green">Я добавил потребный префикс в заголовок темы. Обратите внимание, как сие должно выглядеть.</span></p></blockquote></div><p><span style="color: Green">Изучайте:<br /><a href="http://forum.script-coding.com/rules.html">Правила форума</a></span><br /><span style="color: Green"><a href="http://forum.script-coding.com/viewtopic.php?id=5421">Супер-тема, заходите — не пожалеете</a></span></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-07-17T13:39:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61674#p61674</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: Как скопировать в system32]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=61670#p61670" />
			<content type="html"><![CDATA[<p>Есть текстовый файл, в котором забито имя машины (22tt33), нужно считать из файла имя машины и скопировать в папку С:\WINNT\System32\файл.exe на другой комп, имя считал, все в норме, а вот как заставить скопировать файл не пойму.</p>]]></content>
			<author>
				<name><![CDATA[Starley25]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25241</uri>
			</author>
			<updated>2012-07-17T13:17:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=61670#p61670</id>
		</entry>
</feed>
