Description
The EnableApp tool allows you to enable an application in a farm.
Script Version
1.0
Download
How to Use EnableApp
On the command prompt where the script resides, issue the following command:
> EnableApp.wsf <ApplicationEnableName>
Code Snippet
Search through all applications in the farm to find the application. If the application exists, load the application object:
app1.Initialize MetaframeWinAppObject,appDN
app1.loaddata(true)
Enable the application:
Save the application:
Disclaimer
These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.
This is nice unless you need to disable/enable multiple apps at once. I use the code below to change the app state of all apps listed in a text file.
--
code--On Error Resume Next
'To disable a list of apps uncomment Appstate="Off" and comment out AppState="On"
'AppState="On"
AppState="Off"
AppList = "c:\scripts\applist.txt" 'location of list of apps to change
'Declare constants - do not modify
Const MetaframeWinAppObject=3
Const ForReading = 1
'This section points the script to a text file that has a list of each app to be disabled/enabled
'Only 1 app name per line
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTxt = oFSO.OpenTextFile(AppList, ForReading)
'Script connects to the farm
set farm=createobject("metaframecom.metaframefarm")
farm.initialize 1
' Loops through the list of apps and disables them 1 at a time
Do Until oTxt.AtEndOfStream
sApp = oTxt.Readline
For each app in farm.applications
If ucase(app.appname)=ucase(sApp) then
appDN=app.distinguishedname
Call SetAppState()
End If
Next
Loop
'Clean up
oTxt.Close
set farm=Nothing
set app1=Nothing
set oTxt=Nothing
set oFSO=Nothing
'Sub routine to change the state of the App
Sub SetAppState()
set app1=createobject("Metaframecom.metaframeapplication")
app1.Initialize MetaframeWinAppObject,appDN
app1.loaddata(true)
Select Case AppState
Case "On"
app1.EnableApp=1
Case "Off"
app1.EnableApp=0
Case Else
'insert error here
End Select
app1.savedata()
'WScript.Echo "Application: "&Ucase(appinput)&" Is enabled"
End Sub