Is there a commandline to permit add-ins without the task host configuration?

Anyone know an efficient way to permit add-ins from the task host configuration without using the UI?
image

--Back up database before running query. 

Declare @HostName nVarChar(25)
Set @HostName = N'swk-unknown1'    --<< Update with the system hostname of the task host to add

------------- Verification START
--Check that database is valid
Declare @SelectedDatabaseName nvarchar(250)
Set @SelectedDatabaseName = (SELECT db_name())

IF OBJECT_ID ('SPU_UnlockFile', 'P') IS NULL
begin
  RAISERROR( 'The selected database "%s" does not appear to be an SOLIDWORKS PDM database. Make sure you select correct database to run script on.', 16, 1, @SelectedDatabaseName )
  Return
end

------------- Verification END

Begin Transaction

Declare @IsSuccess int
Set @IsSuccess = 0

--Insert into host table if not already there
Declare @CheckHostID INT
Set @CheckHostID = (Select HostID from Hosts where HostName = @HostName)

if( @CheckHostID IS NULL )
begin
  Insert Into 
    Hosts( HostName )
  Select @HostName
  Where
    Not Exists( Select H.HostId From Hosts H Where H.HostName = @HostName )
	and @HostName != 'CLIENT_HOSTNAME' 
end 

--Catch errors
if( @@ERROR <> 0 )	goto Err  	

Declare @HostID INT
Set @HostID = (Select HostID from Hosts where HostName = @HostName)

Insert Into HostReactors
Select @HostID, ReactorID, 1
From Reactors
Where Contents like '%TaskAddIn.dll%'
and @HostID IS NOT NULL
and Not Exists( Select HR.HostID From HostReactors HR 
				Where HR.HostID = @HostID And HR.ReactorID IN 
					(Select ReactorID From Reactors
					 Where Contents like '%TaskAddIn.dll%'))

--Catch errors
if( @@ERROR <> 0 )	goto Err 

--All is OK. Proceed with updates
Commit transaction

set @IsSuccess = 1
	
Err:
	--Rollback transaction if something goes wrong
	if(@IsSuccess = 0 )
		Rollback transaction
1 Like

How did you figure that out? Documentation or Experimentation?

Yup, it’s documentation.