I wrote this to assist the helpdesk at my work for when they install something or make changes to our Citrix enviroment. We have been using it for a long time and thought I would share, plus its always a good reference of how to use “choice” in bat files.
What this does is first check for admin rights and if admin rights are found then queries the current mode. It then offers 4 choices, 1 – Install mode, 2 – Execute mode, 3 – Cancel and Exit, and 4 – Query Current Mode. If install mode is chosen the mode will be set to install until enter is hit which places the server back into execute which works well if installing many software packages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | :: Change Citrix User Mode @echo off :: check if run under local admin account IF NOT EXIST C:\Users\Administrator\*.* echo Must be run under local admin account. IF NOT EXIST C:\Users\Administrator\*.* echo If available right-click and select "Run as administrator" IF NOT EXIST C:\Users\Administrator\*.* echo Script will now exit. IF NOT EXIST C:\Users\Administrator\*.* pause IF NOT EXIST C:\Users\Administrator\*.* exit C: echo. echo ****************************************************** echo ** ATTENTION!!! Must be ran with Admin credentials ** echo ****************************************************** echo. echo. echo Current Citrix User Mode is: change user /query echo. echo Choose a Mode: echo. echo 1 - INSTALL Mode echo 2 - EXECUTE Mode echo 3 - Cancel and Exit echo 4 - Query Current Mode choice /C:1234 IF errorlevel 4 goto QRY IF errorlevel 3 goto CNL IF errorlevel 2 goto EXE IF errorlevel 1 goto INS #------------------------------------------ :EXE change user /execute echo ********************************** echo **** SERVER IS NOW IN EXECUTE **** echo ********************************** echo. PAUSE CLS echo Current Citrix User Mode is: change user /query echo. echo Choose a Mode: echo. echo 1 - INSTALL Mode echo 2 - EXECUTE Mode echo 3 - Cancel and Exit echo 4 - Query Current Mode choice /C:1234 IF errorlevel 4 goto QRY IF errorlevel 3 goto CNL IF errorlevel 2 goto EXE IF errorlevel 1 goto INS #----------------------------------------------- :CNL exit #---------------------------------------------- :INS change user /install echo ********************************** echo **** SERVER IS NOW IN INSTALL **** echo ********************************** echo **** When finished making **** echo **** changes press "Enter" **** echo ********************************** echo. echo Press enter to return to Execute Mode pause change user /execute echo. echo ********************************** echo **** SERVER IS NOW IN EXECUTE **** echo ********************************** echo. pause cls echo Current Citrix User Mode is: change user /query echo. echo Choose a Mode: echo. echo 1 - INSTALL Mode echo 2 - EXECUTE Mode echo 3 - Cancel and Exit echo 4 - Query Current Mode choice /C:1234 IF errorlevel 4 goto QRY IF errorlevel 3 goto CNL IF errorlevel 2 goto EXE IF errorlevel 1 goto INS #-------------------------------------------- :QRY CLS echo Current Citrix User Mode is: change user /query echo. echo Choose a Mode: echo. echo 1 - INSTALL Mode echo 2 - EXECUTE Mode echo 3 - Cancel and Exit echo 4 - Query Current Mode choice /C:1234 IF errorlevel 4 goto QRY IF errorlevel 3 goto CNL IF errorlevel 2 goto EXE IF errorlevel 1 goto INS |


Posted in
Tags:



