Skip to content

Instantly share code, notes, and snippets.

@valda
Created January 25, 2010 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save valda/285686 to your computer and use it in GitHub Desktop.
Save valda/285686 to your computer and use it in GitHub Desktop.
ntemacs/emacsclientw のラッパスクリプト
'
' C:\emacs23.1\bin\emacsclientw.vbs
'
Set objShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")
Dim emacsProcess
emacsProcess = null
For Each objItem in colItems
If InStr(objItem.CommandLine, "emacs.exe") Then
Set emacsProcess = objItem
End If
Next
If IsNull(emacsProcess) Then
If WScript.Arguments.Count = 0 Then
objShell.Run(fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe")
Else
objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "/runemacs.exe"" """ & WScript.Arguments(0) & """")
End If
Else
If WScript.Arguments.Count = 0 Then
objShell.AppActivate emacsProcess.ProcessID
Else
objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "/emacsclientw.exe"" -n """ & WScript.Arguments(0) & """")
End If
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment