***
*** create_reinstall_license_script.sxscr
***
Let port_at_server = ReadConfigSetting( 'License' , 'NEWTECH_LICENSE_FILE' )

if !StringLength( port_at_server ) then

	*** try harder
	Let info = GetLicenseInfo()
	
	if info[0] == 'NodeLocked' then
		Let msg = '<nobr>You have a portable, or NodeLocked license.</nobr><br />There is no need to run this script.'
	
	elseif info[0] == 'Network' then
		Let msg = 'Something terrible has happened.'
	
	elseif info[0] == 'Unknown' then
		Let msg = '<nobr>You have no license installed.</nobr><br />Close SIMetrix/SIMPLIS and restart, and install license.'
		
	else
		Let msg = 'Something else terrible has happened'
		
	endif
	
	Let MessageBox( msg )
	
elseif port_at_server == '27000@192.168.91.100' then

	Let msg = '<nobr>ERROR: You are attempting to backup the <b>Training Course Server Location</b>.</nobr><br /><br />Because we are nice people, we are not going to allow you to do this, as it would possible overwrite your <b>Corporate Server Location</b>, which would then be quite difficult to retrieve.'

	Let MessageBox( msg )

else

	Echo
	Echo { 'Your Corporate Server Location Is:' }
	Echo { port_at_server }
	
	Let file_contents = [ '***' ,
+				'*** reinstall_corporate_license.sxscr' , 
+				'***' , 
+				'' , 
+				'Let success = WriteConfigSetting( ''License'' , ''LicenseType'' , ''network'' )' ,
+				'Let success = success && WriteConfigSetting( ''License'' , ''NEWTECH_LICENSE_FILE'' , ' & Chr(34) & Chr(39) & port_at_server & Chr(39) & Chr(34) & ' )' ,
+				'Let success = success && WriteConfigSetting( ''License'' , ''PDT_LICENSE_FILE'' , ' & Chr(34) & Chr(39) & port_at_server & Chr(39) & Chr(34) & ' )' ,
+				'' , 
+				'if success then' ,
+				Chr(9) & 'Let ' & Chr(34) & 'MessageBox( ''<nobr>Corporate License Reinstalled Successfully.</nobr><br />Using port@server : ' & port_at_server & '<br /><br />Restart SIMetrix/SIMPLIS to use your Corporate License.' & Chr(39) & ' )' & Chr(34) ,
+				'endif' ]
	
	Let filename = GetSimetrixFile( 'script' , '' , 'reinstall_corporate_license.sxscr' )
	
	if StringLength( filename ) then
		Show /plain /file { filename } file_contents
	endif
endif
