|
1 | 1 | import vscode = require('vscode');
|
2 | 2 | import Window = vscode.window;
|
3 |
| - |
4 |
| - |
5 |
| -/** |
6 |
| -function convertUriToPath(Uri) { |
7 |
| - |
8 |
| - window.showInformationMessage(Uri) |
9 |
| - var result = Uri.replace("file://","") |
10 |
| - var result = result.replace("/","\") |
11 |
| - var driveletter = result.substring(0) |
12 |
| - var result = driveletter + ":" + result.substring(1,-1) |
13 |
| - |
14 |
| -} |
15 |
| -*/ |
| 3 | +import os = require('os'); |
16 | 4 |
|
17 | 5 | export function registerOpenInISECommand(): void {
|
18 | 6 | var disposable = vscode.commands.registerCommand('PowerShell.OpenInISE', () => {
|
19 | 7 |
|
20 | 8 | var editor = Window.activeTextEditor;
|
21 | 9 | var document = editor.document;
|
| 10 | + |
| 11 | +var uri = document.uri |
| 12 | + |
| 13 | +// For testing, to be removed |
| 14 | +Window.showInformationMessage(uri.fsPath); |
| 15 | +Window.showInformationMessage(uri.path); |
| 16 | + |
| 17 | +if (os.arch()== 'x64') { |
| 18 | + |
| 19 | + var ISEPath = 'C:\\Windows\\Sysnative\\WindowsPowerShell\\v1.0\\powershell_ise.exe'; |
| 20 | + |
| 21 | +} else |
| 22 | +{ |
| 23 | + |
| 24 | + // Need to figure out how to check OS architecture os.arch returns process architecture |
| 25 | + //var ISEPath = process.env.windir + '\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe'; |
| 26 | + var ISEPath = 'C:\\Windows\\Sysnative\\WindowsPowerShell\\v1.0\\powershell_ise.exe'; |
| 27 | + |
| 28 | +} |
| 29 | + |
| 30 | +// For testing, to be removed |
| 31 | +Window.showInformationMessage(os.arch()); |
| 32 | +Window.showInformationMessage(ISEPath); |
22 | 33 |
|
23 |
| - //process = require('child_process'); |
24 |
| - //var filePath = convertUriToPath(editor.document.uri); |
25 |
| - var filePath = 'C:\temp\Get-ProductKey.ps1' |
26 |
| - //require("child_process").exec('powershell_ise.exe -NoProfile -File "C:\\temp\\Get-ProductKey.ps1"').unref(); |
27 |
| - require("child_process").exec(process.env.windir + '\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe -NoProfile -File "C:\\temp\\Get-ProductKey.ps1"').unref(); |
| 34 | + require("child_process").exec(ISEPath + ' -NoProfile -File ' + uri.fsPath).unref(); |
28 | 35 |
|
29 | 36 |
|
30 | 37 | });
|
|
0 commit comments