Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
March 20, 2006
If you wanted to set the current directory to the parent folder of a fully qualified file name:
Dim fso, oArgsSet oArgs = WScript.ArgumentsFQFN = oArgs(0)Set fso = CreateObject("Scripting.FileSystemObject")GetTheParent = fso.GetParentFolderName(FQFN)oShell.currentdirectory = GetTheParent
cscript //nologo c:utiltest2.vbs %Systemroot%SYSTEM32DRIVERStcpip.sysreturns:C:WINDOWSSYSTEM32DRIVERSC:C:WINDOWSSYSTEM32DRIVERSwhere test2.vbs contains:Dim fso, oArgsSet oArgs = WScript.ArgumentsFQFN = oArgs(0)Set fso = CreateObject("Scripting.FileSystemObject")GetTheParent = fso.GetParentFolderName(FQFN)Wscript.Echo GetTheParentset oShell = createobject("wscript.shell")wscript.echo oShell.currentdirectoryoShell.currentdirectory = GetTheParentwscript.echo oShell.currentdirectory
You May Also Like