Jump to content

File Explorer window prompt to store file location to variable?

Recommended Posts

Hi guys, I tried looking for this answer but I couldn't find it through a google search so I'm going to attempt this here.

I'm trying to make a script that has all of the configurations of installation and settings changes hard coded but I want the user to be able to run the program installer from wherever they want including a UNC path and despite file name. I'm brand new to this and haven't started working with GUIs yet but I got a script working that allows me to install and configure my first program. However, it runs via the local path of the script: 

                                                                                                                  Run(@ScriptDir & "\ClassicShellSetup_4_3_1.exe")

I'd like to have a variable set in the Run() function parameter that points to a file path so that the program can run despite location and set that variable as a permanently saved variable that can be invoked when the program is run.


The reason I want to do this is because we have alot of different clients and I want to set their installers path once so if a tech comes in they can run a client automation program install from the server after the installer path is set once.

I'd like to use the file browser so they can type a UNC path to the server share and select file path so it passes it and saves the value and the AutoIT script handles the file from there.

I am not nearly as pro as you guys so I'm sorry if this is a stupid question. This is my first day working on this. Any help would be greatly appreciated!

Link to post
Share on other sites
  • 1 month later...

hi @AR-9


welcome to the forum!

you propably didn't receive an answer, because it's hard to guess, what you need exactly.

To permanently store information for other installations done later on you could use an INI file on some file share, every client has access to with write permissions.




if $UNC=$Default Then
    $NewValue=InputBox("Enter UNC path for setups","This computer's name is " & @ComputerName,$ValueSample)
    MsgBox(0,"Value found","Installation UNC path is:" & @CRLF & $UNC)

another approach would be to store your path to the Registry.


See help file for RegRead() and RegWrite()


For user with usual rights choose some key below HKCU


CU, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to post
Share on other sites

I've been playing around with this for a lil just for fun.  Highly doubtful that this suits your needs but it seems useful.  Its pretty slow bc autoit just is that way.  Anyways this just kinda shows a filepathdialog window that you can use to select a general directory, then create your directory to install to.  But instead of the need to save your folder path somewhere what i wrote traverses the directories recursively and searches for your folder avoiding a couple of key folders that would make it take way longer.  you could also loop through drive letters and look through different drives. Even if the drive doesn't exist it would just return.  But the registry key is probably the best way to go. 

$path=FileSelectFolder("choose install path",@ProgramFilesDir,0,@ProgramFilesDir)


$folder = "myfolder"

func GetDirectories($directory)
    $search=FileFindFirstFile($directory & "\*")
    if $search=-1 then return -1
    while true
        if @error then ExitLoop
        if StringInStr(FileGetAttrib($directory & "\" & $file),"D") Then
            if not IsArray($a) Then
                Dim $a[1]
                ReDim $a[UBound($a)+1]
    Return $a

func walk_directories($directory, ByRef $targetfolder)
static $escape=True
    if not IsArray($directories) then Return

    for $i=0 to UBound($directories) - 1
        if Not $escape then ExitLoop

        if StringInStr($directories[$i],$targetfolder) Then
            $targetfolder=$directory & "\" & $directories[$i]
        ElseIf Not StringInStr($directories[$i],"Windows") and not StringInStr($directories[$i],"Microsoft") and Not StringInStr($directories[$i],"Recycle") and $escape Then
            $cc_dir=$directory & "\" & $directories[$i]


Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...