Link to home
Start Free TrialLog in
Avatar of Sumesh BNR
Sumesh BNRFlag for India

asked on

get the current working directory in vb script

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"

oShellLink.Save


Thanks
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

See this script as an example.

http://www.computerperformance.co.uk/ezine/ezine119.htm

replace the working folder with this:
http://leereid.wordpress.com/2008/03/19/vbscript-current-directory-or-folder/

Set oShell = CreateObject(”WScript.Shell”)
Set ofso = CreateObject(”Scripting.FileSystemObject”)
oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)
Avatar of Sumesh BNR

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial