I am trying to create a vbscript macro which would get the folder location in which the macro is stored and create the output files into the same folder. I am using the below co
https://msdn.microsoft.com/en-us/library/22dyy47c%28v=vs.84%29.aspx
That is not how the method works - it extracts the "parent" from the string provided.
Option Explicit
Dim fso,GetTheParent
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName("C:\Windows")
wscript.echo "Attempt 1:" & "'" & GetTheParent & "'"
GetTheParent = fso.GetParentFolderName("\Windows")
wscript.echo "Attempt 2:" & "'" & GetTheParent & "'"
GetTheParent = fso.GetParentFolderName("Windows")
wscript.echo "Attempt 3:" & "'" & GetTheParent & "'"
GetTheParent = fso.GetParentFolderName("C:\WINDOWS\system32")
wscript.echo "Attempt 4:" & "'" & GetTheParent & "'"
GetTheParent = fso.GetParentFolderName("\WINDOWS\system32")
wscript.echo "Attempt 5:" & "'" & GetTheParent & "'"
Results:
Attempt 1:'C:\'
Attempt 2:''
Attempt 3:''
Attempt 4:'C:\WINDOWS'
Attempt 5:'\WINDOWS'