Skip to content

Instantly share code, notes, and snippets.

@ytez
Created April 16, 2021 06:30
Show Gist options
  • Select an option

  • Save ytez/0d644d0a8317e01a7ee31024bc4c7e26 to your computer and use it in GitHub Desktop.

Select an option

Save ytez/0d644d0a8317e01a7ee31024bc4c7e26 to your computer and use it in GitHub Desktop.
@echo off
set CYGROOT=C:\cygwin
start "" PowerShell.exe -ExecutionPolicy RemoteSigned "$Env:CHERE_INVOKING=1; %CYGROOT%\bin\bash --login -i"
<?xml version="1.0"encoding="utf-8" ?>
<package>
<job>
<script language="VBScript">
<![CDATA[
Option Explicit
Dim html: Set html=CreateObject("htmlfile")
''--- Display MsgBox while launching Cygwin
html.parentWindow.setTimeout GetRef("CygStart"), 100
MsgBox "Starting Cygwin ...", vbOkOnly + vbInformation, "Cygwin"
Sub CygStart()
Dim wShell: Set wShell = CreateObject("WScript.Shell")
Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject")
''--- Move current direcroty when argv[0] exists
Dim objArgs: Set objArgs=WScript.Arguments.Unnamed
If objArgs.Count > 0 Then
Dim argPath: argPath = objArgs.Item(0)
If FSO.FolderExists(argPath) Then
wShell.CurrentDirectory = argPath
End If
End If
''--- Lauching Cygwin in current directory
wShell.Environment("User").Item("CHERE_INVOKING") = 1
'' wShell.Run "D:\cygwin\bin\bash --login -i"
Dim cmd: cmd = "PowerShell.exe -ExecutionPolicy RemoteSigned -Command ""C:\cygwin\bin\bash --login -i"""
wShell.Run cmd, 1, False
WScript.Timeout=1
Set FSO = Nothing
Set wShell = Nothing
End Sub
]]>
</script>
</job>
</package>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment