Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 12-01-2009
Member
 
Join Date: Jan 2009
Posts: 96
How to make use of VB Script to get Current Directory?

Hello,

How can i use VBScript to get the current directory? so if i run test.vbs in C:\data

I want to figure out that I am running in C:\data from test.vbs.

Any ideas?

Thanks
Reply With Quote
  #2  
Old 12-01-2009
Member
 
Join Date: Mar 2008
Posts: 232
Re: How to make use of VB Script to get Current Directory?

here you will get some useful script that would get the current directory your script is running from. This is great for referencing other files.

http://leereid.wordpress.com/2008/03...ory-or-folder/

Pretty simple one to follow, it grabs the script name (with path), finds the length, grabs the script name by itself, finds the length, subtracts and you?re left with the path. Too easy, but really useful.

Very good, however this is more simpler:

Set oShell = CreateObject(?WScript.Shell?)
Set ofso = CreateObject(?Scripting.FileSystemObject?)
oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)
Reply With Quote
  #3  
Old 12-01-2009
Member
 
Join Date: Mar 2008
Posts: 227
Re: How to make use of VB Script to get Current Directory?

Hi,
Do this:

Dim sCurPath
CurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")


I hope this solve your problem.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to make use of VB Script to get Current Directory?"
Thread Thread Starter Forum Replies Last Post
How can I create shell script which find out who the active, current user is? mANICKAVASAN Windows Software 4 20-10-2010 11:56 AM
Get latest updated file from your Current Working Directory REDBULL Software Development 4 10-07-2010 02:38 PM
Batch script to delete directory Logan 2 Software Development 4 01-04-2010 12:31 PM
Retrieving the current directory in batch Jacques25 Software Development 3 15-07-2009 11:36 PM
How to get current directory Scott2580 Software Development 3 11-10-2008 03:40 PM


All times are GMT +5.5. The time now is 08:14 AM.