Vincent Belaïche
2013-07-10 10:16:43 UTC
Hello,
I have written the following script
'#######################################################################
Dim oFSO
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject" )
Const iIS_DIRECTORY = 16
Const iIS_READ_ONLY = 1
Function HasWriteAccess(sFolderName_IN) 'As String
Dim oFolder
Set oFolder = oFSO.GetFolder(sFolderName_IN)
Dim iAttr
iAttr = 0
On Error Resume Next
iAttr = oFolder.Attributes
Set oFolder = Nothing
If ((iAttr And 16 ) <> 0) And ((iAttr And 1 ) = 0) Then
HasWriteAccess = "true"
Else
HasWriteAccess = "false"
End If
End Function
Dim oWshShell, sPrograms, sWritablePrograms
Set oWshShell = WScript.CreateObject("WScript.Shell" )
sPrograms = oWshShell.SpecialFolders("Programs")
sWritablePrograms = HasWriteAccess(sPrograms)
WScript.Echo "Programs=" & sPrograms
WScript.Echo "WritablePrograms=" & sWritablePrograms
'######################################################################
and when I run it the response is as follows:
'######################################################################
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.
Programs=C:\Documents and Settings\Vincent\Menu Démarrer\Programmes
WritablePrograms=false
'######################################################################
Now, this answer seems wrong to me, because if I open some command line
console and I do:
Rem ###################################################################
cd /D "C:\Documents and Settings\Vincent\Menu Démarrer\Programmes"
mkdir toto
Rem ###################################################################
That will work without error, i.e. --- contrary to the script response I
do have write access on special folder "Programs".
Any help is welcome.
Vincent.
I have written the following script
'#######################################################################
Dim oFSO
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject" )
Const iIS_DIRECTORY = 16
Const iIS_READ_ONLY = 1
Function HasWriteAccess(sFolderName_IN) 'As String
Dim oFolder
Set oFolder = oFSO.GetFolder(sFolderName_IN)
Dim iAttr
iAttr = 0
On Error Resume Next
iAttr = oFolder.Attributes
Set oFolder = Nothing
If ((iAttr And 16 ) <> 0) And ((iAttr And 1 ) = 0) Then
HasWriteAccess = "true"
Else
HasWriteAccess = "false"
End If
End Function
Dim oWshShell, sPrograms, sWritablePrograms
Set oWshShell = WScript.CreateObject("WScript.Shell" )
sPrograms = oWshShell.SpecialFolders("Programs")
sWritablePrograms = HasWriteAccess(sPrograms)
WScript.Echo "Programs=" & sPrograms
WScript.Echo "WritablePrograms=" & sWritablePrograms
'######################################################################
and when I run it the response is as follows:
'######################################################################
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.
Programs=C:\Documents and Settings\Vincent\Menu Démarrer\Programmes
WritablePrograms=false
'######################################################################
Now, this answer seems wrong to me, because if I open some command line
console and I do:
Rem ###################################################################
cd /D "C:\Documents and Settings\Vincent\Menu Démarrer\Programmes"
mkdir toto
Rem ###################################################################
That will work without error, i.e. --- contrary to the script response I
do have write access on special folder "Programs".
Any help is welcome.
Vincent.