Skip to content

Script Commands

Bashar Astifan edited this page Jan 6, 2022 · 14 revisions

Back to Commander

General Commands

Defines

define: used to define/update new variable

COMMAND STRUCTURE: define [variableName];, variableValue

if the variable already defined will be updated with the new value

You can use value from another variable as ID

EXAMPLE: define [variableName];, [sourceVariableName]

As Commander compiler based on text replacements.. large text could break the script this will help to resolve the issues when your data contains multi lines


set: used to set new value for specific variable

COMMAND STRUCTURE:

set [variableName];, variableValue

IS IT SAME AS define?

No, with set command you can deal with specific values as listed below:

  • ++: set [variableName];, ++
  • --: set [variableName];, --
  • +(varaible or number): set [variableName];, +value
  • -(variable or number): set [variableName];, -value
  • *(variable or number): set [variableName];, *value
  • /(variable or number): set [variableName];, /value
  • any string/numeric value: set [variableName];, value

you can also increase the value directly:

[variableID]++, [variableID]--

If you want to set value from another variable as ID

EXAMPLE:

define [variableName];, [sourceVariableName]

this will help to resolve the issues when you data contains multi lines


func: used to define/update new function

COMMAND STRUCTURE:

func [functionName];, (command)

use call command to invoke the function

EXAMPLE:

func [variableName]{
command1
command2
}

If you want inline syntax, you can define multiple command by split them with !#! or \n

func [variableName];, (command1!#!command2!#!command3)

to call the function use call command:

EXAMPLE: call [functionName]

EXAMPLE (With Parameters): call [variableID]|paramName1:Value|paramName2:Value..etc


call: run commander command from variable

COMMAND STRUCTURE:

call [variableID]

This will solve the issues that could happen because of multiple internal commands

Use definec to define new command with variable

or get the command from file

Please note that call command can be used with sub command

like you can use it with loop, each..etc

You can send custom param to the define command

EXAMPLE:

call [variableID]|paramName1:Value|paramName2:Value..etc


clean/clear: clean all stored variables, storage items, processes, timers..etc

COMMAND STRUCTURE:

clean/clear all

if you want to avoid any conflict or unwanted results use this command at the top of each script



Includes

include: used to include another script into the current one

COMMAND STRUCTURE:

include [fileID]


includel: used to include another script into the current one

COMMAND STRUCTURE:

includel fileLocation

the file should be available in the files storage

you can include any file in the script folder by it's name (for script bundle)

EXAMPLE:

includel extraContent.wutc



Strings

regex: extract string using regex

COMMAND STRUCTURE:

regex [variableID];, pattern;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT)
regex [testID];, \(.*\);, [sourceID]

testID will be (WUT)

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


regexg: extract string using regex with group

COMMAND STRUCTURE:

regexg [variableID];, pattern;, group;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT)
regexg [testID];, Welcome (?<middle>\w+);, middle;, [sourceID]

testID will be To

as you can see this will return only the requested group

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


regexc: extract string collection using regex with group

COMMAND STRUCTURE:

regexc [variableID];, pattern;, group;, [targetID]

pattern like:

define [sourceID];, Welcome To (WUT) Welcome test collection
regexc [testID];, Welcome (?<middle>\w+);, middle;, [sourceID]

testID will be To,test

as you can see this will return only the requested group

be aware to the special chars \ - ( - < -> and don't forget to add \ before them \ - ( - < - >

if you got any parsing error message then you have special char in your pattern


replace: replace content with another content

COMMAND STRUCTURE:

replace [targetID];, original;, replacement

The results will be saved to the same variable

you can replace multiple words at once

replace [targetID];, w1|w2|w3;, r1|r2|3

You can replace multi target with one source:

replace [targetID];, w1|w2|w3;, r1


replaced: replace content with another, then define result

COMMAND STRUCTURE:

replaced [outputVariable];, [targetID];, original;, replacement

outputVariable will be defined by default

multi replace available as in replace command


replacer: replace content with another content using regex

COMMAND STRUCTURE:

replacer [outputVariable];, [targetID];, regex;, replacement

outputVariable will be defined by default

multi replace available as in replace command but use '[#]' separator instead of |


substr: get sub string using start, end index

COMMAND STRUCTURE:

substr [variableID];, [targetID];, startIndex;, endIndex

if you want to set 'end' to the last index use 'last' instead of number


length: get length for string variable

COMMAND STRUCTURE:

length [variableID];, [targetID]



Arrays

Basically Commander array is string value divided by specific char, default is ,

most array commands will give you the option to set the separator char

count: get items count for array variable

COMMAND STRUCTURE:

count [variableID];, [targetID];, separator


subarr: get sub array using start, end index

COMMAND STRUCTURE:

subarr [variableID];, [targetID];, separator;, startIndex;, endIndex

if you want to set 'end' to the last index use 'last' instead of number


unique: delete duplicated values

COMMAND STRUCTURE:

unique [variableID];, [arrayID];, separator

EXAMPLE:

define [arrayID];, "A", "B", "C", "D","A"
unique [cleanArray];, [arrayID];, ,

cleanArray-> "A", "B", "C", "D"

you can use the [arrayID] as string instead of ID, just write the arrayID without []


sort: will sort data by AES, DESC

COMMAND STRUCTURE:

unique [variableID];, [arrayID];, separator;,, sortType

sortType: can be aes or desc

EXAMPLE:

define [arrayID];, "A", "B", "C", "D","A"
unique [cleanArray];, [arrayID];, ,;, aes

cleanArray-> "A","A", "B", "C", "D"

you can use the [arrayID] as string instead of ID, just write the arrayID without []


reformat: merge two values into one

This is very important command for arrays, it will help to build values for any GUI command

COMMAND STRUCTURE:

reformat [variableID];, values1;, values2;, mixSymbol;, separator

EXAMPLE:

define [Values1];, "United State", "United Kingdom", "China"
define [Values2];, "us", "uk", "cn"
reformat [CountriesArray];, Values1;, Values2;, :;, |

CountriesArray -> "United State":"us"|"United Kingdom":"uk"|"China":"cn"

you can use these values into list or combo

if you want to remove " you can call replace command

replace [CountriesArray ];, ";,

then the output will be:

CountriesArray -> United State:us|United Kingdom:uk|China:cn

Note: The command currently work only with values separated with ,

so if your input value using something else use replace command first


Working with index:

How to get specific index from variable?

if you sure that your variable contains value as array use this: variableID:(index,separator)

index can be number or first, last

EXAMPLE:

In storage our data is like this: variableID -> value1, value2, value3

with this command: variableID:(last,,) will return value3

or this command: variableID:(1,,) will return value2

you can also get the item with it's index (whatever it was text or array):

[variableID][index]



Areas

area: used to define custom area like 'label' in CMD

COMMAND STRUCTURE:

area [areaName];, (command)


jump: used to jump to specific area like 'goto' in CMD

COMMAND STRUCTURE:

jump [areaName]



Runtime

delay: used to delay the script for specific time

COMMAND STRUCTURE:

delay time

time in milliseconds


break: used to break the execution and end the script

COMMAND STRUCTURE:

break message


breakwhen: used to break the execution and end the script on specific condition

COMMAND STRUCTURE:

breakwhen condition;, message

check 'is' command below for condition structure

you can use fixed condition 'offline' to break when no internet connection

check also waitic (for wait until internet active)



Batch Script

cmd: run cmd command from variable

COMMAND STRUCTURE:

cmd [variableID]

check definec / func for commands define


cmdout: run cmd command and save the output result to variable

COMMAND STRUCTURE:

cmdout [outputID];, (command)



Conditions

is: used to execute command when specific condition is true

COMMAND STRUCTURE:

is statement;, (command)

statement accept the following operators:

  • <
  • >
  • >=
  • <=
  • equ
  • ==
  • neq
  • !=
  • lss
  • leq
  • gtr
  • geq
  • ~~ (contains)
  • !~ (not contains)
  • @ (startWith)
  • # (endWith)

EXAMPLE:

is variable<18;, (break Age is not allowed)

variable (left side) can be also [variableID], because long data/text with lines will break the script

  1. You can test upto 3 values instead of two

is variable==11|18|22;, (break Age is not allowed)

  1. You can run cmd commands with 'is'

  2. You can use mulitple commands with 'is'

EXAMPLE:

is variable>0{
command..
command..
}
  1. You can get lower case content for the left side

is lower:content~~test;, (command)

  1. Internal multiple is is possible

else: used to execute command after 'is' condition is false

COMMAND STRUCTURE:

else statement;, (command)

if you don't have extra statement just use 'else'

if you want to use else without statement in one line do the following:

else (command)

multi line is possible

EXAMPLE:

is variable>0{
.....
}else statement{
.....
}

any other details same exactly as 'is' command



Loops

loop: create loop with specific rounds

COMMAND STRUCTURE:

loop startIndex;, endIndex;, step;, (command)

To get the current index use $currentIndex

  • You can run cmd commands directly
  • You can use skip, break in-commands

skip: will skip the current iteration

break: will break the loop

if you want to execute multiple commands the do these steps:

  1. Create func
  2. Call the function with call inside the (command)

EXAMPLE:

func [test]{
..command..
..command..
}

loop startIndex;, endIndex;, step;, (call [test])

each: create loop with specific value (for arrays)

COMMAND STRUCTURE:

each [arrayID];, separator;, (command)

To get the current value use $currentValue

  • You can run cmd commands directly
  • You can use skip, break in-commands

skip: will skip the current iteration

break: will break the each loop



Files / Folders

folder: used to select specific folder

COMMAND STRUCTURE:

folder [folderID];, extensions

extensions should be like .appx|.msix

folderID will be stored during the session so yo can use it from any other script

folderID will be replaced with folder path during the compiling

  • use 'name:folderID' to get ONLY the name not the full path
  • use 'size:folderID' to get folder total size formatted like 15.3 MB
  • use 'sizelong:folderID' to get the total size in bytes like 15300000
  • use 'date:folderID' to get modified date & time
  • use 'count:folderID' to get total files count

folderf: used to select specific folder inside another folder (without picker)

COMMAND STRUCTURE:

folderf [folderID];, [parentID];, folderName


file: used to select specific file

COMMAND STRUCTURE:

file [fileID];, extensions

extentions should be like .appx|.msix

fileID will be stored during the session so yo can use it from any other script

fileID will be replaced with file path during the compiling

  • use 'name:fileID' to get ONLY the name not the full path
  • use 'size:fileID' to get file size formatted like 2.5 MB
  • use 'sizelong:fileID' to get file size in bytes like 2500000
  • use 'date:fileID' to get modified date & time
  • use 'nameonly:fileID' to get modified date & time
  • use 'extonly:fileID' to get modified date & time

filef: used to select specific file inside folder (without picker)

COMMAND STRUCTURE: filef [fileID];, [folderID];, fileName


filel: used to select specific file inside folder (without picker) by location

COMMAND STRUCTURE:

filel [fileID];, fileLocation

the file should be available in the files storage

if fileLocation contains " it will be removed by default


files: used to select specific files (multiple selection)

COMMAND STRUCTURE:

files [filesID];, extensions

extensions should be like .appx|.msix

filesID will be stored during the session so yo can use it from any other script

filesID will be replaced with files paths during the compiling

when no files selected the filesID will be null

OUTPUT EXAMPLE: File1Path, File2Path, File3Path

  • use 'name:filesID' to get only the name not the full path
  • use 'size:filesID' to get file size formatted like 2.5 MB, 1.5 MB, 3 KB
  • use 'sizelong:filesID' to get file size in bytes like 2500000, 1500000, 3000
  • use 'count:filesID' to get total files count
  • use 'date:filesID' to get modified date & time
  • use 'namesize:filesID' to get name and size in this format fileName (Size)
  • use 'nameonly:filesID' to get modified date & time
  • use 'extonly:filesID' to get modified date & time

filesf: used to select specific files from folder (without picker)

COMMAND STRUCTURE:

filesf [filesID];, [folderID];, extensions

filesID will handle the selected files

extensions should be like .appx|.msix

descriptions same as files command


pick: used to re-select specific file/folder

COMMAND STRUCTURE:

pick [targetID]

extensions should be like .appx|.msix


exists (1.0.4+): used to check if the file exists using the full path

COMMAND STRUCTURE:

exists [variableID];, fullPath

will return true or false

EXAMPLE:

exists [testID];, c:\text.txt
is testID==true{
//Your code goes here
}

crc (1.0.4+): used to get unique identifier for any file using fileID

COMMAND STRUCTURE:

crc [variableID];, [fileID]

it's very helpful to compare the files


crcl (1.0.4+): used to get unique identifier for any file using full path

COMMAND STRUCTURE:

crcl [variableID];, filePath

it's very helpful to compare the files the file should be available in the files storage


get: used to get file content

COMMAND STRUCTURE:

get [targetID];, [variableID]

if variableID not defined before will be automatically defined

simple content will work fine with dialogs


getl: used to get file contents by location

COMMAND STRUCTURE:

getl fileLocation;, [variableID]

this command will look into the storage and get the file when it's exists

the file should be available in the files storage


append: used to append content to specific file

COMMAND STRUCTURE:

append [targetID];, content

content can be [variableID]


write: used to write content to specific file

COMMAND STRUCTURE:

write [targetID];, content

content can be [variableID]


open: used to open file/folder with the default launcher by ID

COMMAND STRUCTURE:

open [targetID]


openl: used to open file/folder with the default launcher by location

COMMAND STRUCTURE:

openl fileLocation

this command will look into the storage and open the file when it's exists

the file should be available in the files storage

if fileLocation contains " it will be removed by default


openf: used to open file inside folder

COMMAND STRUCTURE:

openf [folderID];, fileName

if fileName contains " it will be removed by default


create: used to create new folder

COMMAND STRUCTURE:

create [folderID];, [parentID];, folderName

folderID will be added to the session storage


createf: used to create new file inside existed folder

COMMAND STRUCTURE:

createf [fileID];, [folderID];, fileName

fileID will be added to the session storage


delete: used to delete folder or file by ID

COMMAND STRUCTURE:

delete [targetID]

targetID can be for folder or file and compiler will search for it automatically


deletef: used to delete file inside folder

COMMAND STRUCTURE:

deletef [folderID];, fileName


play: play audio file/SFX

COMMAND STRUCTURE:

play [folderID];, fileName;, volume

volume in double between 0.0 - 1.0

To use app sound effects:

play [$Assets];, SFX\$AppIcons\error.mp3;, 1.0

Available sfx:

  • ac-off.mp3
  • ac-on.mp3
  • alert.mp3
  • error.mp3
  • no-results.mp3
  • started.mp3

Working with path:

You can get custom part of the path in case your variable is path

available options: name, nameonly, extonly

EXAMPLE:

define [pathVariable];, C:\testfile.exe

//Get 'testfile.exe'
name:pathVariable 

//Get 'testfile'
nameonly:pathVariable

//Get '.exe'
extonly:pathVariable


Waiters

hold: will hold all the script processes

COMMAND STRUCTURE:

hold state

state can be 0 or 1

You can use the waitb command to be able to release the hold state


waitf: will hold the script until the specific file found

COMMAND STRUCTURE:

waitf fileName;, waitMessage;, timeout;, (timeoutCommand)

set timeout to 0 to ignore the timeout limit OR don't include it

timeoutCommand will be called only if the file not found during the specific time

if you want to delete the file after wait use '|1' with the name

EXAMPLE:

waitf test.txt|1;, Please wait..

again don't add timeout if you don't want to use it

timeout in milliseconds

because of UWP restriction this command will look in three places:

  • cache folder
  • downloads folder
  • script folder (if possible)

if you have your own folder and already selected use waitfd


waitfd: will hold the script until the specific file found

COMMAND STRUCTURE:

waitfd [folderID];, fileName;, waitMessage;, timeout;, (timeoutCommand)

set timeout to 0 to ignore the timeout limit OR don't include it

timeoutCommand called only if the file not found during the specific time

EXAMPLE:

waitfd [$LocalFolder];, test.txt|1;, Please wait..

other details same as waitf command


waitn: will hold the script until the notification pressed

COMMAND STRUCTURE:

waitn waitTitle;, waitMessage;, timeout

set timeout to 0 to ignore the timeout limit

don't add timeout if you don't want to use it

timeout in milliseconds


waitd: will hold the script until specific file downloaded

COMMAND STRUCTURE:

waitd [downloadID];, waitMessage

this command interact with download command only (not the repos downloads)


waite: will hold the script until specific file extracted

COMMAND STRUCTURE:

waite [downloadID];, waitMessage

this command interact with download command only (not the repos downloads)


waiti: will hold the script until specific file installed

COMMAND STRUCTURE:

waiti [queueID];, [outputState];, waitMessage

this command interact with download command only (not the repos downloads)

queueID or downloadID

outputState will help you to know if the app installed or not

because the waiti will be skipped if the app installed or failed


waitic: will hold the script until internet available

COMMAND STRUCTURE:

waitic message


waitp: will hold the script until the progress reach 'x' percentage

COMMAND STRUCTURE:

waitp waitMessage;, targetPercentage

targetPercentage as number like 40, 50 or 100..etc


waitpr: will hold the script until the specific process start/end

COMMAND STRUCTURE:

waitpr waitMessage;, processName

processName: Executable File Name like svchost.exe

if appDiagnostics is not allowed the command will be ignored

if you want to wait until the process end add '!' before the name

EXAMPLE:

waitpr waitMessage;, !processName


waitb: used to show break-wait button near to the script

COMMAND STRUCTURE:

waitb buttonTitle

use waithb buttonTitle command to hide the button



Links / Downloads

response: used to check the response for specific URL

COMMAND STRUCTURE:

response [responseID]; url

will return 0 if response failed

or will return StatusCode..:

Ok: the request susccess

NotFound

404: Page Not Found

for more read about StatusCodes: Click Here

use [responseID]|C to get the response content (in command structure)

use cancelb to cancel the request if you want


download: used to download file by link

COMMAND STRUCTURE:

download [downloadID];, fileLink

use waitd if you want to wait until the file downloaded

by default new variable will be defined to handle the file name

just place downloadID to get the file name


downloadf: used to download files form links in a file

COMMAND STRUCTURE:

downloadf [downloadID];, [folderID];, fileName

All downloads will be added to Group Downloads section


downloadfd: used to download files form links in a file

COMMAND STRUCTURE:

downloadfd [downloadID];, [folderID];, fileName;, [saveFolderID]

All downloads will be added to Group Downloads section You can download from list of links in variable

EXAMPLE:

downloadfd [downloadID];, [variableID];, local;, [saveFolderID]

if your list contains links separated with custom char use: local:(,)

You can use some custom option with the fileName:

fileName|IE and fileName|SD

you can also use both of them fileName|SD|IE

IE: mean to ignore the files if already exists

SD: mean to add the download file to Single downloads queue

You can use custom save folder name:

[saveFolderID]|customFolderName


cancelb Show cancel button under the script

COMMAND STRUCTURE:

cancelb buttonTitle

to hide the button use cancelhb buttonTitle

the button also will be hidden once the script finished/terminated this command for downloadf / downloadfd / response commands only


browse: used to invoke the built-in browser and open specific website

COMMAND STRUCTURE:

browse webLink


luri: used to launch file, app, link using URI

COMMAND STRUCTURE:

luri uri



Queue

queuef: used to queue file inside folder

COMMAND STRUCTURE:

queuef [queueID];, [folderID];, fileName

if fileName contains " it will be removed by default

if the file is media, commander will launch media viewer


queuel: used to queue file by it's location

COMMAND STRUCTURE:

queuef [queueID];, fileLocation

if fileLocation contains " it will be removed by default

this command will look into the storage and queue

if the file is media, commander will launch media viewer

the file should be available in the files storage


queuer: remove the downloaded / added file from the queue

COMMAND STRUCTURE:

queuer [downloadID]

this command interact with download / queuef / queuel commands only

downloadID or queueID

Use $ScriptID to remove the current script from the queue



Dialogs

The default values for dialogs buttons(button1->1, button2->2) unless you customize it

info: used to display info dialog with one button

COMMAND STRUCTURE:

info title;, message;, button

message can be styled by using the following words:

Red Words: important | be careful | error

Orange Words: note | note 1 | note 2 | warning

Green Words: remember | report | success

(upper or lower) no rule for the case (important, Important or IMPORTANT)

for new line add \n between the lines

Add |telnet to button to prevent the text wrapping

You can use the variable as ID in case it's contains lines

EXAMPLE: info title;, Hello [variableID];, button


text: used to display text dialog (from variable Only)

COMMAND STRUCTURE:

text title;, [variableID];, button

Add |telnet to button to prevent the text wrapping


ask: used to display question dialog with two buttons

COMMAND STRUCTURE:

ask [dialogID];, title;, question;, button1;, button2

you can add default value to any button: button|defaultValue

message can be styled as in the info dialog

for new line add \n between the lines

You can use the variable as ID in case it's contains lines

EXAMPLE:

info title;, Hello [variableID];, button


input: used to display input dialog with two buttons

COMMAND STRUCTURE:

input [dialogID];, title;, placeholder;, button1;, button2

you can add default value to any button: button|defaultValue

the default value for button1 will be returned only if the input is empty

input can be extended with descriptions option

EXAMPLE:

input [dialogID];, title;, descriptions;, placeholder;, button1;, button2


slider: used to display slider dialog with two buttons

COMMAND STRUCTURE:

slider [dialogID];, title;, range;, button1;, button2

range structure is: min|max|step

you can use min|max|step|after|before

you can use |#P in anywhere with the range to convert the value from percentage to double, exam.. 125% -> 1.2 [0|250|1|#P|%]

after, before will be added to the preview text

EXAMPLE:

slider [ageDailog];, Select your age;, 15|55|1;, Confirm|18;, Cancel

you can add default value to any button: button|defaultValue


combo: used to display combo dialog with two buttons

COMMAND STRUCTURE:

combo [dialogID];, title;, list;, placeholder;, button1;, button2

list structure is: item1|item2|item3...etc

EXAMPLE:

you can add default value to any button: button|defaultValue

if you want to use View text and value:

list structure is: item1:value1|item2:value2|item3:value3...etc

in this case you the value for the default button value: button|value1

using reformat command:

reformat [refValues];, name:filesID;, filesID;, :;, |
combo [comboID];, title;, refValues;, placeholder;, Select|refValues:(first,,);, Cancel

EXPLAIN:

reformat will merge the two values into one

Values 1: Name1, Name2..etc

Values 2: Path1, Path2..etc

refValues: Name1:Path1|Name2:Path2..etc


comboi: used to display combo dialog with extra input

COMMAND STRUCTURE:

comboi [dialogID];, title;, list;, placeholder;, extraElement;, button1;, button2

descriptions same as combo command

extraElement can be: input or slider

input structure: input|placeholder (empty input will return null)

slider structure: slider|min|max|step (same as rang in slider command)


list: used to display list dialog with two buttons

COMMAND STRUCTURE:

list [dialogID];, title;, data;, header;, button1;, button2

header is the header text

data structure is: item1|item2|item3..etc

this dialog will return the value of the selected item

same data list structure as in combo applied

when no selection will return null


listm: used to display multi-select list dialog with two buttons

COMMAND STRUCTURE:

listm [dialogID];, title;, data;, header;, button1;, button2

header is the header text

data structure is: item1|item2|item3..etc

this dialog will return the value of the selected items (as array)

SAMPLE OUTPUT:

value1, value3, value 5..etc

other descriptions same as list command

same data list structure as in combo applied

you can use '*' in button1 default value to select all the items

EXAMPLE: button1|*

when no selection will return null


image: used to display image dialog with two/one buttons

COMMAND STRUCTURE:

image [dialogID];, title;, [imageFile];, button1;, button2

image [dialogID];, title;, descriptions;, [imageFile];, button1;, button2

you can add default value to any button: button|defaultValue

if you want only one button just use empty value for button2


video: used to display video dialog with two/one buttons

COMMAND STRUCTURE:

video [dialogID];, title;, [videoFile];, button1;, button2

video [dialogID];, title;, descriptions;, [videoFile];, button1;, button2

you can add default value to any button: button|defaultValue

if you want only one button just use empty value for button2

Clone this wiki locally