Remote Desktop Shortcuts |
This is an example of how remote desktop connection shortcuts could be created. This macro could be configured to be useful outside of MAKEMSI, for example by invoking a small script via PPWIZARD to create the files directly in the start menu!
The following code tests the macros which are defined below:
;---------------------------------------------------------------------------- ;--- Test Creation of Remote Desktop (terminal services) Shortcuts ---------- ;---------------------------------------------------------------------------- #define SCRD_BRANCH_AU Branch Servers\AU #define SCRD_BRANCH_NZ Branch Servers\NZ <$ScRemoteDesktop> <$ScRemoteDesktopSc Host="BRANCHAU001" ScDir="<$SCRD_BRANCH_AU>"> <$ScRemoteDesktopSc Host="BRANCHAU002" ScDir="<$SCRD_BRANCH_AU>"> ;... <$ScRemoteDesktopSc Host="BRANCHNZ99" ScDir="<$SCRD_BRANCH_NZ>"> <$/ScRemoteDesktop>
This is the reusable code which could be placed into your configuration header file:
;---------------------------------------------------------------------------- ;--- Create Macros ---------------------------------------------------------- ;---------------------------------------------------------------------------- #define? REMOTEDESKTOPSC_ROOTDIR <$MAKEMSI_OTHER_DIR>\ScRemoteDesktop #define? REMOTEDESKTOPSC_ROOTDIR_SC [StartMenuFolder]\$$$RemoteDesktop$$$ ;;If empty not creating shortcuts (makes it useful outside of MAKEMSI) #define? REMOTEDESKTOPSC_IN_DOCO N ;;Show as file in doco? #define? REMOTEDESKTOPSC_DEFAULT_DOMAIN #define? REMOTEDESKTOPSC_DEFAULT_SCREENX 1024 #define? REMOTEDESKTOPSC_DEFAULT_SCREENY 768 #define? REMOTEDESKTOPSC_DEFAULT_SCREEN_MODE 2 ;;2=Fullscreen 1=? #define? REMOTEDESKTOPSC_DEFAULT_SCREEN_BPP 8 ;;BitsPerPixel: 8=256 colors (fastest) #( #define ScRemoteDesktopSc ;--- Make sure we are nested within a "ScRemoteDesktop" block ----------- #if [RxRemoteDesktopStartedAt = ''] ;--- We haven't started one yet! ------------------------------------ #error ^You haven't started a "ScRemoteDesktop" yet!^ #endif ;--- Create the "shortcut" from a template ------------------------------ #output '<$REMOTEDESKTOPSC_ROOTDIR>\{$ScDir=^^}\{$Title=^{$Host}^}.rdp' ASIS #( '<?NewLine>' screen mode id:i:{$ScreenMode=^<$REMOTEDESKTOPSC_DEFAULT_SCREEN_MODE>^} desktopwidth:i:{$ScreenX=^<$REMOTEDESKTOPSC_DEFAULT_SCREENX>^} desktopheight:i:{$ScreenY=^<$REMOTEDESKTOPSC_DEFAULT_SCREENY>^} session bpp:i:{$BBP=^<$REMOTEDESKTOPSC_DEFAULT_SCREEN_BPP>^} winposstr:s:0,1,174,23,974,623 full address:s:{$Host} compression:i:1 keyboardhook:i:2 audiomode:i:0 redirectdrives:i:0 redirectprinters:i:1 redirectcomports:i:0 redirectsmartcards:i:1 displayconnectionbar:i:1 autoreconnection enabled:i:1 username:s:{$UserId=^^} domain:s:{$Domain=^<$REMOTEDESKTOPSC_DEFAULT_DOMAIN>^} alternate shell:s: shell working directory:s: disable wallpaper:i:1 disable full window drag:i:1 disable menu anims:i:1 disable themes:i:1 disable cursor setting:i:0 bitmapcachepersistenable:i:1 #) #output #) #RexxVar RxRemoteDesktopStartedAt = ^^ #( ;--- START of remote desktop definitions -------------------------------- #define ScRemoteDesktop ;--- Nesting validation -------------------------------------------------- #PUSH "ScRemoteDesktop" #if [RxRemoteDesktopStartedAt <> ''] ;--- We haven't finished the previous one yet! ---------------------- #error ^You can't nest the "ScRemoteDesktop" command!{NL}Previous remote desktop started at: <??RxRemoteDesktopStartedAt>^ #endif #RexxVar RxRemoteDesktopStartedAt = ^<?=GetInputFileNameAndLine()>^ ;--- Remove any existing shortcuts from previous builds ----------------- #if DirQueryExists('<$REMOTEDESKTOPSC_ROOTDIR>') <> '' #evaluate ^^ ^call AddressCmd 'rd "<$REMOTEDESKTOPSC_ROOTDIR>" /q /s >nul <$Stderr2Out>'^ #if DirQueryExists('<$REMOTEDESKTOPSC_ROOTDIR>') <> '' #error ^We are trying to clear all previously generated remote desktop shortcuts.{NL}{NL}Failed deleting the directory (probably in use):{NL}{NL} <$REMOTEDESKTOPSC_ROOTDIR>^ #endif #endif #) #( ;--- END of remote desktop definitions ---------------------------------- #define /ScRemoteDesktop ;--- Nesting validation -------------------------------------------------- #if [RxRemoteDesktopStartedAt = ''] ;--- We haven't started one yet! ------------------------------------ #error ^You haven't started a "ScRemoteDesktop" yet!^ #endif #POP "ScRemoteDesktop" #RexxVar RxRemoteDesktopStartedAt = ^^ ;--- We expect to have seen at least one remote desktop ----------------- #if DirQueryExists('<$REMOTEDESKTOPSC_ROOTDIR>') = '' #error ^The directory "<$REMOTEDESKTOPSC_ROOTDIR>" doesn't exist (no shortcuts)!^ #elseif ;--- Have shortcuts (want to add them to an MSI?) ------------------- #if ['<$REMOTEDESKTOPSC_ROOTDIR_SC>' <> ''] ;--- Being used in MAKEMSI to create shortcuts (not creating shortcuts "directly") --- <$Files "<$REMOTEDESKTOPSC_ROOTDIR>\*.*" DestDir="<$REMOTEDESKTOPSC_ROOTDIR_SC>" SUBDIR="TREE" DOCO="<$REMOTEDESKTOPSC_IN_DOCO>"> ;--- Need to ignore some validation messages -------------------- <$MsiValFilter "It must use a registry key under HKCU as its KeyPath, not a file"> <$MsiValFilter "in the user profile but is not listed in the RemoveFile table"> #endif #endif #)