I ended up putting this script together. It does several things for me:
- finds my dropbox path, computer name (for ID purposes) and outputs that to a text file in %A_Temp%. I have other scripts that reads that file into variables.
- then it checks for/creates a Lib directory and xcopys over files as needed based on file date
- runs the rest of my ahk startups.
Seems to do all I need and it is machine/structure independent (as far as I can tell so far).
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; dropbox path
EnvGet, appdata_Loc, LOCALAPPDATA
FileRead, string, %appdata_Loc%\DropBox\info.json
Path_Loc := (InStr(string, "path", false)) + 8
Host_Loc := (InStr(string, "host", false)) - 4
Path_Len := Host_Loc - Path_Loc
DB_Path := StrReplace(SubStr(string, Path_Loc, Path_Len), "\\", "\")
;
; todo path
ToDo_Path = %DB_Path%\todo
;
; machine name
RegRead, Mach_Name, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName, ComputerName
;
; write sections
IniWrite, %DB_Path%, %A_Temp%/AHK.txt, DropBox, Location
IniWrite, %ToDo_Path%, %A_Temp%/AHK.txt, ToDo, Location
IniWrite, %Mach_Name%, %A_Temp%/AHK.txt, Machine, Name
;
; setup library
Source = %DB_Path%\AHK\Lib
Destination = %A_MyDocuments%\AutoHotkey\Lib
IfNotExist, %A_MyDocuments%\AutoHotkey\Lib
FileCreateDir, %A_MyDocuments%\AutoHotkey\Lib
Run % comspec " /c xcopy """ Source """ """ Destination """ /d"
;
; complete bootup
startup_file = AHK Startup - %Mach_Name%.ahk
Run %DB_Path%\AHK\%startup_file%
;
exitapp