TheTypist
TheTypist

Reputation: 1

How do I create a powershell script to set default file type (.ica specifically) to open with a .exe located in C:\program files (x86)\

Users must install Citrix Connection Manager to work from home.

Often, their default program to open .ICA files is set to a browser or nothing at all.

Some users don't know how to do this and still have issues with a very thorough step-by-step guide. Once the user has installed the CCM, it's located at C:\Program Files (x86)\Citrix\ICA Client\wfcrun32.exe.

Unable to find previous scripts that successfully complete this task.

Upvotes: 0

Views: 336

Answers (1)

mklement0
mklement0

Reputation: 439777

  • The following uses cmd.exe's internal assoc and ftype commands to associate .ica files with a self-created file type named CitrixConnection, which means that such files will open with the executable specified as part of the file-type definition.

    • As internal cmd.exe commands, they must be called via cmd /c from PowerShell.
  • These commands require elevation to run, because they create machine-level (all-users) definitions.

    • It is possible to create user-level definitions, but doing so would require direct manipulation of the Windows registry.
#requires -RunAsAdministrator

# NOTE: There must be NO SPACE before `&&`, as that space would
#       otherwise become part of the argument value (even with "..." quoting).
cmd /c @"
assoc .ica="CitrixConnection"&& ftype CitrixConnection="C:\Program Files (x86)\Citrix\ICA Client\wfcrun32.exe"
"@

Note the use of an (expandable) here-string (@"<newline>...<newline>"@) so as to make use of embedded quoting easier.


To later remove these definitions, run:

#requires -RunAsAdministrator

# NOTE: There must be NO SPACE before `&`.
quoting).
cmd /c 'assoc .ica=& ftype CitrixConnection='

Upvotes: 0

Related Questions