Re Testing for Hidden Files
Document Sample


Re: Testing for Hidden Files
Re: Testing for Hidden Files
Source:
http://www.tech−archive.net/Archive/Windows/microsoft.public.windows.server.scripting/2007−08/msg00156.html
• From: "ThatsIT.net.au" <me@thatsit>
• Date: Sun, 26 Aug 2007 00:53:57 +0800
OK I have made a change, if that does not work let me know. WScript.Echo will not work in VB.net msgbox
will. but you would probably would like to write results top a file.
to test if a folder is hidden, "Change computer names"
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("TRY","hank")
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Directory
WHERE name = 'C:\\Scripts'", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
For Each objItem In colItems
MSGBOX "Hidden: " & objItem.Hidden
Next
Next
"Donald Fisher" <dsfcom@xxxxxxx> wrote in message
Re: Testing for Hidden Files 1
Re: Testing for Hidden Files
news:ub9Ks6o5HHA.5984@xxxxxxxxxxxxxxxxxxxxxxx
I'm trying to run this in an app created by MS Visual Studio. It works as just a .vbs file but I
need more than that.
ThatsIT.net.au wrote:
Where are you running this
the code below looks like ASP.Net
the script I sent you runs in a vbs file.
place in notepad and save with vbs extension then execute it
"Donald Fisher" <dsfcom@xxxxxxx> wrote in message
news:%23F2Q%23Gn4HHA.5804@xxxxxxxxxxxxxxxxxxxxxxx
Still errors.
−−−−−
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
WScript.Echo("Test")
End Sub
−−−−−
Error message from MVS 2005−−
−−−−−− Build started: Project: TESTS, Configuration:
Debug Any CPU −−−−−−
D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Vbc.exe
/noconfig
/imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System
/nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
/rootnamespace:WindowsApplication1
/doc:obj\Debug\TESTS.xml
/define:"CONFIG=\"Debug\",DEBUG=−1,TRACE=−1,_MyType=\"WindowsForms\",PLATF
/reference:D:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,D:\WINDO
/main:WindowsApplication1.My.MyApplication /debug+
/debug:full /out:obj\Debug\TESTS.exe
/resource:obj\Debug\WindowsApplication1.Form1.resources
/resource:obj\Debug\WindowsApplication1.Form2.resources
/resource:obj\Debug\WindowsApplication1.Resources.resources
/target:winexe Form1.vb Form1.Designer.vb
Form2.Designer.vb Form2.vb "My
Project\AssemblyInfo.vb" "My
Project\Application.Designer.vb" "My
Project\Resources.Designer.vb" "My
Re: Testing for Hidden Files 2
Re: Testing for Hidden Files
Project\Settings.Designer.vb"
H:\VBS_05_PROJ\TESTS\TESTS\Form1.vb(4) : error
BC30451: Name 'WScript' is not declared.
H:\VBS_05_PROJ\TESTS\TESTS\Form2.vb(4) : error
BC30451: Name 'WScript' is not declared.
========== Build: 0 succeeded or up−to−date, 1 failed, 0
skipped ==========
Donald Fisher wrote:
Found download location:
http://www.microsoft.com/downloads/info.aspx?na=22&p=1&SrcDisplayLang=en&S
Need to restart to test again.
Donald Fisher wrote:
It errors. I'm running in
circles with MS on a WSH
download. Can't seem to
find it? The latest version is
5.6 but MS site doesn't seem
to have it available?
ThatsIT.net.au wrote:
try running
a script with
just
WScript.Echo
"Test"
if that errors
you may
not have
WSH
installed.
"Donald
Fisher"
<dsfcom@xxxxxxx>
wrote in
message
news:uy0pLpc4HHA.600@xxxxxxxxxxxxxxxxxxxxxxx
Re: Testing for Hidden Files 3
Re: Testing for Hidden Files
I
get
an
error
when
it
get's
to
the
WScript
part.
ThatsIT.net.au
wrote:
your
current
code
does
not
tell
you
if
its
hidden,
mine
dose.
the
script
checks
computers
named
TRY
and
HANK,
and
searches
for
a
folder
called
c:\scripts
you
need
to
make
changes
to
make
Re: Testing for Hidden Files 4
Re: Testing for Hidden Files
it
work.
"Donald
Fisher"
<dsfcom@xxxxxxx>
wrote
in
message
news:O7fCA$E4HHA.1208@xxxxxxxxxxxxxxxxxxx
Can't
get
to
work?
My
current
code
is:
−−−−−−
Set
objFSO
=
CreateObject("Scripting.FileSystemObject")
Set
objFolder
=
objFSO.GetFolder("H:\MyFolder\")
If
objFolder.Attributes
=
objFolder.Attributes
AND
2
Then
objFolder.Attributes
=
objFolder.Attributes
XOR
2
msgbox
"Complete!",vbokonly,"
Done
−"
End
If
−−−−−−
This
only
works
Re: Testing for Hidden Files 5
Re: Testing for Hidden Files
as
a
switch.
I'd
like
to
see
if
the
folder
is
already
hidden
and
only
hide
it
if
it's
not.
ThatsIT.net.au
wrote:
to
test
if
a
folder
is
hidden,
"Change
computer
names"
On
Error
Resume
Next
Const
wbemFlagReturnImmediately
=
&h10
Const
wbemFlagForwardOnly
=
&h20
arrComputers
=
Re: Testing for Hidden Files 6
Re: Testing for Hidden Files
Array("TRY","hank")
For
Each
strComputer
In
arrComputers
Set
objWMIService
=
GetObject("winmgmts:\\"
&
strComputer
&
"\root\CIMV2")
Set
colItems
=
objWMIService.ExecQuery("SELEC
*
FROM
Win32_Directory
WHERE
name
=
'C:\\Scripts'",
"WQL",
_
wbemFlagReturnImmediately
+
wbemFlagForwardOnly)
For
Each
objItem
In
colItems
WScript.Echo
"Hidden:
"
&
objItem.Hidden
Next
Next
Re: Testing for Hidden Files 7
Re: Testing for Hidden Files
"Donald
Fisher"
<dsfcom@xxxxxxx>
wrote
in
message
news:umz2mDh2HHA.4400@xxxxx
I
have
scripts
for
hiding/un−hiding
folders
but
would
like
to
learn
how
to
test
whether
or
not
the
folder(s)
are
already
hidden
or
not
(basically
all
I
have
is
an
on/off
switch
at
the
moment).
Also,
I'd
like
to
create
a
Re: Testing for Hidden Files 8
Re: Testing for Hidden Files
script
that
will
tell
Windows
Explorer
to
not
show
hidden
files
and
test
whether
or
not
"Show
Hidden
Files"
is
already
enabled
or
not.
Thanks
for
any
help.
Don
.
Re: Testing for Hidden Files 9
Get documents about "