# shell.exec2

0th

Percentile

##### Open a file or URL using Windows File Associations

Open a file or URL using Windows File Associations using shell.exec() but makes some tweaks to filenames to make them more likely to be opened properly.

This function is only applicable on Windows systems.

Keywords
file, IO
##### Usage
shell.exec2(file)
##### Arguments
file

A character string specifying a file or an URL.

##### Details

Before passing a file on the file system to shell.exec(), this function: (i) unmaps any mapped drive letters used in the pathname (e.g. 'X:/foo.bar.html' to 'C:/Users/Joe/bar.html'), (ii) and replaces any forward slashed with backward ones (e.g. 'C:/Users/Joe/bar.html' to 'C:\Users\Joe\bar.html'). URLs are passed as is to shell.exec().

The reason for (i) is that some web browsers (e.g. Google Chrome) will not open files on mapped drives. The reason for (ii) is that if forward slashes are used, then shell.exec() will give an error that the file was not found (at least with the default Windows shell).

Returns nothing.

##### Setting on startup

The intended usage of this function is to set it as the default browser for browseURL. Just add the following to your .Rprofile file:

    if (.Platform\$OS.type == "windows")
options(browser=function(...) R.utils::shell.exec2(...))


This will only load (not attach) the R.utils package when the browser function is actual used.

##### Aliases
• shell.exec2
Documentation reproduced from package R.utils, version 2.9.2, License: LGPL (>= 2.1)

### Community examples

Looks like there are no examples yet.