From Q version 5.18.1 onwards, users can now run their own QScripts from a local folder and have them appear as a menu in Q.
Requirements
- Q version 5.18.1 and above.
- By default, the menu will be called Custom Scripts, and will load any QScript files located in:
C:\Users\<user name>\AppData\Roaming\Q\Custom Scripts.
- If you specify a different folder, the name of the menu in Q will match the name of the folder.
- In Q version 5.18.1 only those QScripts immediately in the specified folder will show. However, from 5.18.4, Q can now load scripts from any series of sub-folders within the primary folder.
Method 1 - Manual
1. Close all instances of Q.
2. Select your Windows icon key and search for the Registry Editor.
3. Open the Registry Editor and navigate to HKEY_CURRENT_USER\Software\Q.
4. On the right of the screen, right-click > New > String Value and change the name to CustomScriptsDirectory.
5. Right-click the CustomScriptsDirectory file and select Modify to set the correct directory path for Value data.
Note, you must ensure that the directory path string has back slashes and is not enclosed in quotation marks.
6. Open Q.
7. The new registry will now be added in the Automate menu between Browse Online Library and Recently Used.
Method 2 - Automated
A second method for updating the registry is to use the following PowerShell script.
# Set variables to indicate value and key to set
$RegistryPath = 'HKCU:\Software\Q'
$Name = 'CustomScriptsDirectory'
$Value = "$env:APPDATA\Q\CustomScripts"
# Create the key if it does not exist
If (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
# Now set the value
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType String -Force
What you will need to do is as follows:
1. Update line 4 with the preferred file directory path by replacing APPDATA\Q\CustomScripts
.
2. Save the script as a Powershell file with "ps1" as the file extension.
3. Open Command Prompt.
4. Paste in the below line and update to match the file name and path of your saved file from step 2:
powershell -noexit "& ""C:\my_path\script_name.ps1"""
5. Press Enter.