Skip to content

Commit 350448f

Browse files
committed
Removed convertUriToPath due to the fact that vscode.window.activeTextEditor.editor.document.uri got an fsPath property which can be used instead. Path to ISE is now set as a variable which will be assigned based on OS architecture.
1 parent 7ca40cc commit 350448f

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/features/OpenInISE.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
import vscode = require('vscode');
22
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');
164

175
export function registerOpenInISECommand(): void {
186
var disposable = vscode.commands.registerCommand('PowerShell.OpenInISE', () => {
197

208
var editor = Window.activeTextEditor;
219
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);
2233

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();
2835

2936

3037
});

0 commit comments

Comments
 (0)