1
votes

I need some help with the appropriate coding to prevent the newly formed EXE from using the TEMP folder as the current working folder.

Using the HTA (no conversion) in any folder works fine and the correct CWD is used.

    Set Sh=CreateObject("WScript.Shell")
    cwd=Sh.CurrentDirectory

Converting to an EXE the program uses the following folder instead of the folder path its being executed in.

file:///C:/Users/username/AppData/Local/Temp/%7B3479C69C-F8A7-4FE0-9903-68266AAF2EA7%7D/test.hta

As I understand it, the converted EXE gets "unpacked" into the temp folder and is run there until it closes, then it automatically deletes itself from temp.

So how do I prevent the EXE from using the temp folder as the CWD instead of the actual folder it is executed in?

Do I need to put in extra code for the user to navigate and select the actual CWD? That seems counter-productive! I would really like a piece of code to read from the actual (true) path of the EXE.

Thanks in advance.

2

2 Answers

0
votes

What tool do you use to convert the script? I use "VBS To EXE" and the current directory always worked well.

I just tested it with your two lines and it worked (I added msgbox cwd and the path was right).

0
votes

I think the 32bit version of vbsedit will also have troubles. Make sure to use the 64bit version.