UNPKG

2.64 kBPlain TextView Raw
1' Copyright (c) 2016, Evgeny Panasyuk
2
3' Permission is hereby granted, free of charge, to any person or organization
4' obtaining a copy of the software and accompanying documentation covered by
5' this license (the "Software") to use, reproduce, display, distribute,
6' execute, and transmit the Software, and to prepare derivative works of the
7' Software, and to permit third-parties to whom the Software is furnished to
8' do so, all subject to the following:
9'
10' The copyright notices in the Software and this entire statement, including
11' the above license grant, this restriction and the following disclaimer,
12' must be included in all copies of the Software, in whole or in part, and
13' all derivative works of the Software, unless such copies or derivative
14' works are solely in the form of machine-executable object code generated by
15' a source language processor.
16'
17' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19' FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20' SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21' FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22' ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23' DEALINGS IN THE SOFTWARE.
24
25' e-mail: E?????[dot]P???????[at]gmail.???
26
27Option Explicit
28
29Dim filename, line, column
30Dim MSVS_versions, version
31Dim dte, fso, wshShell
32Dim fullpath
33
34filename = WScript.Arguments(0)
35line = WScript.Arguments(1)
36column = WScript.Arguments(2)
37
38MSVS_versions = Array _
39( _
40 "VisualStudio.DTE.7", _
41 "VisualStudio.DTE.7.1", _
42 "VisualStudio.DTE.8.0", _
43 "VisualStudio.DTE.9.0", _
44 "VisualStudio.DTE.10.0", _
45 "VisualStudio.DTE.11.0", _
46 "VisualStudio.DTE.12.0", _
47 "VisualStudio.DTE.14.0", _
48 "VisualStudio.DTE.15.0" _
49)
50
51On Error Resume Next
52
53For each version in MSVS_versions
54 Err.Clear
55 Set dte = getObject(,version)
56 If Err.Number = 0 Then
57 Exit For
58 End If
59Next
60
61If Err.Number <> 0 Then
62 Set dte = WScript.CreateObject("VisualStudio.DTE")
63 Err.Clear
64End If
65
66Set wshShell = WScript.CreateObject("WScript.Shell")
67Set fso = WScript.CreateObject("Scripting.FileSystemObject")
68fullpath = fso.GetAbsolutePathName(filename)
69
70dte.MainWindow.Activate()
71dte.MainWindow.Visible = True
72dte.UserControl = True
73wshShell.AppActivate dte.MainWindow.Caption
74
75dte.ItemOperations.OpenFile fullpath
76dte.ActiveDocument.Selection.MoveToLineAndOffset line, column + 1
77
78if Err.Number <> 0 Then
79 WScript.Quit Err.Number
80End If
81
82On Error Goto 0