Jump to content

Remember chosen Directory


Recommended Posts

  • Moderators

I'm hoping this will be a simple fix. I do a lot of packaging of applications, and testing the installs. I wrote the quick script below to allow me to quickly install applications on test machines, rather than having to browse manually or run command line. The script has a function for a basic MSI install, as well as one for an MSI with a Transform file. My question is regarding the MSI and Transform function. I have the script opening a file open dialogue box in the root directory where all projects are stored, and then I browse for the MSI. It then opens back to that same root directory and I browse for the Transform. Is there an easy way to get it to remember and open in the directory where I just chose the MSI? Sometimes I have to browse 8 or 10 folders deep, and it would be nice not to have to do all that clicking more than once.

$var = MsgBox(4, "Test Application", "Does this install require a Transform?")
If $var = 6 Then
  Call("mst")
Else
  Call("msi")
EndIf

func msi()

$value = FileOpenDialog("Test Application Install", "packagingserver[url="file://\\jiminy\packaging"]\[/url]packagingDIR", "All (*.*)")
  Run( 'msiexec /i "' & $value & '" /qb' )
EndFunc

func mst()

$value1 = FileOpenDialog("MSI file", "packagingserver[url="file://jiminy/packaging"]\[/url]packagingDIR", "All (*.*)")
$value2 = FileOpenDialog("Transform file", "packagingserver[url="file://jiminy/packaging"]\[/url]packagingDIR", "All (*.*)") <---------- here is where I'd like to make the change. I would like this dialog box to open in the same directory where I chose the previous file one line above.
  Run( 'msiexec /i "' & $value1 & '" TRANSFORMS="' & $value2 & '" /qb' )
EndFunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Set the second parameter as the starting directory.

Example:

#include <file.au3>

Dim $szDrive, $szDir, $szFName, $szExt

$value1 = FileOpenDialog("MSI file", "C:\temp", "All (*.*)")
$Path = _PathSplit($value1, $szDrive, $szDir, $szFName, $szExt)
$value2 = FileOpenDialog("Transform file", $szDrive & "\" & $szDir, "All (*.*)")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Global $Path = @ScriptFullPath

$Path = FileOpenDialog('Open File', StringRegExpReplace($Path, '\\[^\\]*\Z', ''), 'All Files (*.*)', 1 + 2, StringRegExpReplace($Path, '\.*\Z', ''))
$Path = FileOpenDialog('Open File', StringRegExpReplace($Path, '\\[^\\]*\Z', ''), 'All Files (*.*)', 1 + 2, StringRegExpReplace($Path, '\.*\Z', ''))
$Path = FileOpenDialog('Open File', StringRegExpReplace($Path, '\\[^\\]*\Z', ''), 'All Files (*.*)', 1 + 2, StringRegExpReplace($Path, '\.*\Z', ''))

Edited by Yashied
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...