Packaged script needs to write output file

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
clum09
Posts: 150
Joined: Thu Apr 24, 2008 9:11 am

Packaged script needs to write output file

Post by clum09 »

Hello,

When I package my vbscript file in PrimalScript 2009 to become the .exe file, I have the option to have the extracted script file and the icon file to be placed in a separate folder that is different from the script folder.

In the script code, I have the output log files written to the current folder where the packaged script file (the .exe file) also resides.

When I run the packaged script, the output log files are written to the folder where extracted script file and the icon file are located.

I don't want to hard code the folder location for the output log files in the script since I don't know what folder I will place the packaged script (the .exe file).

How can I have the packaged script write the output log files to the packaged script's current folder while the extracted script file and the icon file be placed in a separate folder?

Thank you in advance.

jvierra
Posts: 14550
Joined: Tue May 22, 2007 9:57 am
Contact:

Packaged script needs to write output file

Post by jvierra »

Sorry - I take that back.

Try this:

Code: Select all

	
MsgBox WScript.Path
Set shell = CreateObject("WScript.Shell")
MsgBox shell.CurrentDirectory
	

CurrentDirectory points to the folder where the script is unpacked.

jvierra
Posts: 14550
Joined: Tue May 22, 2007 9:57 am
Contact:

Packaged script needs to write output file

Post by jvierra »

I guess that means that thius worked. Yes you cannot take the default here as it will place files in the extraction folder. WScript.Path is where WScript (cscript) was launched from. I ssuspect this is local to teh EXE because CSCRIPT is launched as a child of the EXE and would inherit the EXEs environment. This will always be the same.

'CurrentDirectory' will be the location script is that is executing UNDER cscript. This can be changed by the script at any time but will be the script location initially.




Locked