1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Adobe AIR for Desktop ファイルを開く&exeを実行する

Last updated at Posted at 2015-04-04

概要

Adobe AIR for Desktop で、以下のことをします。

  • 特定のファイルをデフォルトのアプリケーションで開く方法(エクスプローラーで docx をダブルクリックすると Word が起動する)
  • 特定のexeファイルを実行する

コード

以下、アプリケーションフォルダにあるファイルを開く想定のコードです。
他のフォルダの指定は、ここにわかりやすくまとまっています。

デフォルトのアプリケーションで開く(例:test.docx)

var file = File.applicationDirectory;
file = file.resolvePath("test.docx");
file.openWithDefaultApplication();

exeを実行する(例:test.exe)

var nativeProcessStartupInfo = new NativeProcessStartupInfo();
var file = File.applicationDirectory;
file = file.resolvePath("test.exe");
nativeProcessStartupInfo.executable = file; 
nativeProcessStartupInfo.workingDirectory = File.documentsDirectory; 
var process = new NativeProcess(); 
process.start(nativeProcessStartupInfo);

補足

exe を実行するときは、基本的に2つめのコードなのですが・・・1つめのコードで開ける exe ファイルもありました。
Windows アプリケーションの仕組みをあまりできていないので、だれか分かる人いたら教えてください。

注記

Windowsでしか動作確認していません。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?