Hello, and Thank you for this quick reply !
This works perfectly, returns the shell output in the variable, then I can further process it in VB, thanks !
The GetAttr returns the expected 32, Archive Bit set.
I have made a little sub to tidy things up :
Option Explicit
Public Function ShellReturn(strShellCommand As String, Optional ImportSheetName As String) As String
Dim str$
'load the Shell Command and return the string
str = Trim(CreateObject("wscript.shell").exec("cmd /c " & strShellCommand).stdout.readall)
' Debug.Print str
'split the string in rows, if linefeed, then in a collection
Dim colStr As New Collection
str = Trim(str)
Do While InStr(str, Chr(10)) <> 0
' str = Left(str, 1)
If Not InStr(str, Chr(10)) = 0 Then 'if we are not on the last row
colStr.Add Left(str, InStr(str, Chr(10)))
' Debug.Print colStr(colStr.Count)
str = Right(str, Len(str) - InStr(str, Chr(10)))
Else 'last row (does not contain any chr(10) = linefeed
colStr.Add str
End If
' Debug.Print str
Loop
Debug.Print colStr.Count
'we can import the elements in a new or an existing sheet for further work
If Not ImportSheetName="" Then
Dim ws As Worksheet
On Error GoTo WorkSheetDoesNotExist 'if the worksheet doesn't exist, we create it
Set ws = ThisWorkbook.Worksheets(ImportSheetName)
On Error GoTo 0
ws.UsedRange.ClearContents
ws.Columns("A:AA").ColumnWidth = 14
Dim c As Range
Set c = ws.Range("A1")
Dim i
For i = 1 To colStr.Count
c.Cells(i, 1) = colStr(i)
Next
ws.UsedRange.WrapText = False
ws.UsedRange.HorizontalAlignment = xlLeft
ws.Range("A1").Select
End If
Exit Function
'###### Error Handling
WorkSheetDoesNotExist: 'The target Worksheet does not exist, so we create it
ThisWorkbook.Worksheets.Add After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Name = ImportSheetName
Resume
End Function