adding all of botlist, initial add
[botlist.git] / botlistprojects / botlistdocs / tools / misc / emacs / e1.vbs
blob4e6d7ae5a85b394653c6311a101d3b14b7e57d1f
1 '**************************************
2 ' Simple script to launch Emacs
3 ' (VB IDE is not required, should work with Windows XP)
4 ' Berlin Brown
5 ' Created 11/20/2007
7 ' Launch with:
8 ' cscript e1.vbs
10 ' See: http://www.emacswiki.org/cgi-bin/emacs-en/EmacsClient#toc3
11 '**************************************
12 Set objShell = WScript.CreateObject("WScript.Shell")
13 Set fso = CreateObject("Scripting.FileSystemObject")
15 '**************************************
16 ' Check if emacs is already running
17 '**************************************
18 strComputer = "."
19 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
20 Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")
21 Dim isRunning
22 isRunning = False
23 For Each objItem in colItems
24 If InStr(objItem.CommandLine, "emacs.exe") Then
25 isRunning = True
26 End If
27 Next
29 If WScript.Arguments.Count = 1 Then
30 If isRunning Then
31 objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\emacsclientw.exe"" -n " & """" & WScript.Arguments(0) & """")
32 Else
33 objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\runemacs.exe"" " & """" & WScript.Arguments(0) & """")
34 End If
36 Else
37 ' ***** Print the Standard Out, the Usage ***********
38 Wscript.StdOut.WriteLine "Running emacs startup (no arguments)"
39 If isRunning Then
40 objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\emacsclientw.exe"" -n C:/test.txt")
41 Else
42 objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\runemacs.exe"" ")
43 End If
45 End If