<?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=7925&amp;type=atom" />
	<updated>2012-12-29T02:13:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7925</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: Проверка существования файла и смена его аттрибута.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=67995#p67995" />
			<content type="html"><![CDATA[<p><span style="color: Green"><strong>Ремер</strong>, используйте <a href="http://forum.script-coding.com/help.php?section=bbcode">тэг «code»</a> для оформления кода на форуме. Я поправил Ваш пост.</span></p><p>Сообщения добавьте сами:<br /></p><div class="codebox"><pre><code>Option Explicit

Dim strFile

With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    strFile = .BuildPath(WScript.CreateObject(&quot;Shell.Application&quot;).NameSpace(&quot;shell:AppData&quot;).self.Path, &quot;Software\Reg\cleanfolders.lst&quot;)
    
    If .FileExists(strFile) Then
        With .GetFile(strFile)
            If Not .Attributes And 1 Then
                .Attributes = .Attributes Or 1
            End If
        End With
    Else
        WScript.Echo &quot;File [&quot; &amp; strFile &amp; &quot;] not found&quot;
    End If
End With

WScript.Quit 0
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2012-12-29T02:13:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=67995#p67995</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: Проверка существования файла и смена его аттрибута.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=67988#p67988" />
			<content type="html"><![CDATA[<p>Необходимо проверить существования файла и если его нет вывести сообщение. Если файл существует то нужно проверить стоит ли у него аттрибут &quot;только чтение&quot;, если&nbsp; стоит вывести сообщение, если же нет, поставить атрибут &quot;только чтение&quot; и вывести сообщение об успехе. </p><p>Вот что делал, но почему то сообщение выводится не зависимо от того есть файл или его нет, с аттрибутами вообще не знаю как. </p><div class="codebox"><pre><code>With WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
    username = wshShell.ExpandEnvironmentStrings(&quot;%username%&quot;) 
    
    If .FileExists(&quot;C:\Documents and Settings\%username%\Application Data\Software\Reg\cleanfolders.lst&quot;) Then
    else
        MsgBox &quot;Файла: cleanfolders.lst  не существует&quot;,64, &quot;Сообщение&quot;
    end if
end with</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ремер]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27916</uri>
			</author>
			<updated>2012-12-28T19:15:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=67988#p67988</id>
		</entry>
</feed>
