|
VBS starting script for latest silly Xwin (cygwin) |
GullRaDriel
Member #3,861
September 2003
|
Hi there. I just though I had to share that basic script I made. As you may or not be aware, latest cygwin installs are pestifered and scripts starting Xwin server always leave a blank windows in the taskbar. Xterm shortcut may not work anymore with dual card settings. Warning, I'm no big VBS user so that script code may not be the best. So, here is the vbs: 1' Stupid Cygwin Xserver launcher
2' by Castagnier Mickal
3' 17/02/2014
4
5Dim cygwin_primary
6Dim cygwin_secondary
7Set objShell = CreateObject("WScript.Shell")
8
9' Path for x64 or x86 in order of preference
10cygwin_primary = "C:\cygwin\bin\run.exe"
11cygwin_secondary = "C:\cygwin64\bin\run.exe"
12
13'
14' cygwin run version check
15'
16Dim cygrunner
17cygrunner = "NO_CYGWIN_RUN_EXECUTABLE"
18Set fso = CreateObject("Scripting.FileSystemObject")
19
20If( fso.FileExists( cygwin_secondary ) )Then
21 cygrunner = cygwin_secondary
22End If
23
24
25If( fso.FileExists( cygwin_primary ) )Then
26 cygrunner = cygwin_primary
27End If
28
29' Error check and display
30If( StrComp( cygrunner ,"NO_CYGWIN_RUN_EXECUTABLE" ) = 0 )Then
31 MsgBox "NO_CYGWIN_RUN_EXECUTABLE in "& cygwin_primary & " or " & cygwin_secondary
32 Wscript.quit 1
33End If
34
35'Start Xwin with cygrunner
36objShell.Run( cygrunner & " /usr/bin/bash.exe -l -c /usr/bin/startxwin" ) , 0
37Wscript.quit 0
I named it startx.vbs and put it in cygwin-X directory in the start menu. For fixing the Xterm shortcut, I had to change the DISPLAY to :0 instead of 127.0.0.1:0 And if Xwin does not keep launched, it's because of an empty startxwinrc or an exiting startxwinrc. Here is mine: Xressource is used to customize the terminal. Hence the call to xrdb inside the startx script. My Xressource, if ever needed by anyone: cat .Xresources Hope it helps ! Cheers ! "Code is like shit - it only smells if it is not yours" |
bamccaig
Member #7,536
July 2006
|
It is 2015. I know, I know, I did it too. Imagine my surprise when I arrived in to work today (Tuesday) after the holiday yesterday and realized a SQL SELECT that I had on screen from Friday that wasn't working was asking for ... WHERE ... BETWEEN ... using February 2014 to fetch logs for recently added functionality... Damn year changes. As a reluctant ASP/VBScript (not necessarily the same as WScripting...) programmer I'd suggest getting rid of the NO_CYGWIN_RUN_EXECUTABLE string and comparison and just check if cygrunner is Null. It should be something like IsNull(cygrunner) if the dialects are compatible. Saves you a bit of complexity. Otherwise, it's fine, as we all know nobody uses VBS by choice... Consider putting it into a GitHub repository so both you'll remember it and other people can maybe find it... I have cmd-su that was once useful for me to launch things from a command prompt as Administrative user in Windows 7 (which IIRC prompts using UAC automatically). Edit: s/Nothing/Null/ ... Nothing is a special kind of null for objects, but that has to be Set explicitly... By default I think the value should be Null... (It has thankfully been a while...). -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
GullRaDriel
Member #3,861
September 2003
|
My, I didn't even noticed that I dated it badly. "Code is like shit - it only smells if it is not yours" |
|