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.
This topic is 13 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.



This topic is 13 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked