get the current working directory in vb script

Sumesh BNR
Sumesh BNR used Ask the Experts™
Hi All,

I have an application that is a portable utility which doesn't require installation  and I used to copy the folder to any where in windows 7 and windows xp  and can execute fine .I want to create a shortcut through a script regardless of where my installation files are located and the script need to automatically select the current directory and make a short cut in windows xp and 7 desktops.I have tried using the batch file but it is copy the setup.exe to desktop and I don't want this because there is config file in this application can any one suggest a way to do this. Also I have tried using the following script . bu T I don't know how to get the current working directory as the oShellLink.TargetPath and oShellLink.WorkingDirectory .Please help

set WshShell = WScript.CreateObject("WScript.Shell" )

strDesktop = WshShell.SpecialFolders("AllUsersDesktop" )

set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut to MissARSSE_PM.exe.lnk" )

oShellLink.TargetPath = "c:\myapp\setup.exe"

oShellLink.WindowStyle = 1

oShellLink.IconLocation = "c:\myapp\Source\icon2.ico"

oShellLink.Description = "Shortcut Script"

oShellLink.WorkingDirectory = "c:\myapp\setup.exe"


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kyle AbrahamsSenior .Net Developer

See this script as an example.

replace the working folder with this:

Set oShell = CreateObject(”WScript.Shell”)
Set ofso = CreateObject(”Scripting.FileSystemObject”)
oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)
I didn't get you .Can you modify the script to get the current working directory as the directory where the script is located .I call my script with myscript.vbs.
Senior .Net Developer
This small script will get you the current directory where the script is running from.

Set oShell = CreateObject("WScript.Shell")
Set ofso = CreateObject("Scripting.FileSystemObject")
oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName) 
msgBox oShell.Currentdirectory

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial