Skip to main content
Known Participant
May 17, 2021
Answered

Disable a startup script

  • May 17, 2021
  • 3 replies
  • 1917 views

Hello guys, I need help on my startup script. Is there a way to disable a script without removing the script file? I dont want to disable it permanently, just like a switch button to enable and disable a startup script. Thank you in advance

This topic has been closed for replies.
Correct answer rob day

Maybe something like this:

 

var isRun;
var theDialog = app.dialogs.add({name:"Startup", canCancel:true});
with(theDialog){
    with(dialogColumns.add()){
        staticTexts.add({staticLabel:"Run Script:"});             
        with(dialogColumns.add()){
            isRun = checkboxControls.add({checkedState:false, minWidth:150});
        }
    }
}
if(theDialog.show()){
    if (isRun = isRun.checkedState) {
        main()
    }else{
        theDialog.destroy();
    }
}


function main(){
    alert("Add listeners here and run script")
};

 

3 replies

Community Expert
May 19, 2021

Hi Joseph Christian,

another option would be a text file that contains the names of all startup scripts.

Every startup script will first read the contents of that text file and look after its own name.

If the name of the startup script is found it will start.

 

Regards,
Uwe Laubender

( ACP )

 

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
May 18, 2021

Maybe something like this:

 

var isRun;
var theDialog = app.dialogs.add({name:"Startup", canCancel:true});
with(theDialog){
    with(dialogColumns.add()){
        staticTexts.add({staticLabel:"Run Script:"});             
        with(dialogColumns.add()){
            isRun = checkboxControls.add({checkedState:false, minWidth:150});
        }
    }
}
if(theDialog.show()){
    if (isRun = isRun.checkedState) {
        main()
    }else{
        theDialog.destroy();
    }
}


function main(){
    alert("Add listeners here and run script")
};

 

Known Participant
May 18, 2021

thank you @brian_p_dts @rob day 

brian_p_dts
Community Expert
Community Expert
May 17, 2021

Startup scripts, by their nature, run at startup. If you don't want the script to run at startup, just put it in your regular scripts folder and run it when you want to. Or you can include Event Listeners in the startup script to trigger or not based on desired functionality. Really depends on the script and what you're trying to enable or disable.