Automatically starting turnkey3 – Windows7

I had a need to do this, and this is my solution for running a “live” hercules system running turnkey3 from either a USB stick or a DVD image.

The only difference between the two is that if the .bat file detects it is running from a DVD or CDROM it will use a config using C:\TEMP for disk shadow files, print, punch and log files (and be unable to use tapes), if run from a USB it will use the USB for all its work files, and not use the host disk at all.

The filesystem includes the native windows hercules programs, wc3270 (the windows port of x3270), a turnkey3 system, and of course an autorun.inf to start hercules/telnet/3270 screens. Exactly the same filesystem for both media.

You will notice all the config pastes are from a unix server :-), thats my environment. I have already
documented
how to automatically start hercules and TK3 on a headless linux server
, this post is how to do it on windows.

My directory layout is as below, just hercules, wc3270 and turnkey3

[mark@phoenix USB DISK]$ find ./ -type d
./                                     <-- the autorun.inf covered below
./hercules
./hercules/wc3270                      <== wc3270
./hercules/wc3270/html
./hercules/hercules-3.05               <== windows hercules
./hercules/hercules-3.05/html
./hercules/hercules-3.05/html/Images
./hercules/hercules-3.05/html/include
./hercules/hercules-3.05/util
./hercules/turnkey3                    <== copy of a working tk3 system
./hercules/turnkey3/conf
./hercules/turnkey3/daemons
./hercules/turnkey3/dasd
./hercules/turnkey3/jcl
./hercules/turnkey3/log
./hercules/turnkey3/pch
./hercules/turnkey3/prt
./hercules/turnkey3/shadow             
./hercules/turnkey3/standalone
./hercules/turnkey3/supplied
./hercules/turnkey3/supplied/jcl
./hercules/turnkey3/supplied/scripts
./hercules/turnkey3/tapes
[mark@phoenix USB DISK]$

One important thing to note is that I have created a /hercules/turnkey3/hercules.rc to do the IPL; as I wanted a totally hands off startup. The hercules.rc file just contains

[mark@phoenix turnkey3]$ cat hercules.rc

pause 20
ipl 148

As Windows7 doesn't allow autorun for USB media (I believe it still does for CD media) I chose to just use an AutoPlay configuration which should work on both. In the USB or CD root directory my autorun.ing file is as below

[mark@phoenix USB DISK]$ cat autorun.inf
[AutoRun]
; Volume and icon to be displayed
label="MVS38J"
icon=\hercules\hercules-3.05\hercules.exe,0
; run this program
shellexecute=\hercules\autostart.bat
UseAutoPlay=1
; the below shows in first line of autoplay menu, describe shellexecute
action=Run Hercules (MVS38J)
; the below options appear when drive letter is right clicked
shell\runherc\command=\hercules\autostart.bat
shell\runherc=Run Hercules (MVS38J)
; the bolw is invoked when drive letter is double clicked, runs the above
shell=runherc
[IgnoreContentPaths]
\hercules\wc3270
\hercules\MVS38J

All the work is in the batch file that gets run when it is selected by AutoPlay via one of the methods in the autorun.inf, and the contents of that are as below

[mark@phoenix hercules]$ cat autostart.bat
@ECHO OFF
REM ###################################################
REM Autostart script.
REM Do our best to autorun the MVS3.8J system
REM
REM (1) Change the PATH to point to the hercules and
REM wc3270 files
REM (2) Try and work out if we are running off a cdrom
REM (which would autorun) or a USB/external disk
REM as if a cdrom we cannot write to it so must
REM use a different config that will use C:\temp
REM (3) Work out what windoze version we are running
REM under. The START command won't work before XP
REM I'm still not sure the batch commands used
REM will work under XP, but say we won't run under
REM anything prior to XP and hope XP works
REM (4) start hercules, and wait for 5 seconds for it
REM to initialise
REM (5) start the telnet and 3270 sessions needed
REM (6) show the what to do next
REM ###################################################

REM We need to use a different config file if this is on a CDROM
REM as we can't write to the CDROM for the shadow files.
set mydrive=%~dp0%
set mydrive2=%mydrive:~0,3%
reg query hklm\system\mounteddevices|findstr /C:"5C003F00"|findstr /C:"DosDevices\%mydrive2%"
IF %ERRORLEVEL% EQU 0 goto iscdrom
SET config="conf\marks.conf"
goto checkver
:iscdrom
SET config="conf\marks_cdrom.conf"
ECHO "Detected this is running from CDROM, will use C:\TEMP for shadow disks"
ECHO "N O T E : Tapes are not shadowed, so any tape write operations will fail on livecd"
ECHO ""
ECHO "B E F O R E P R O C E E D I N G"
ECHO ""
ECHO "Please check you have a C:\TEMP directory, create if needed."
ECHO "Windowze 7 doesn't seem to have one by default, and the live CDROM will crash without it"
ECHO "Hit enter when you have confirmed you have a C:\TEMP directory for disk shadow files"
ECHO "--> shadow files are used for disk writes needed when the 'master' disk images are"
ECHO " write protected (ie: paging space must be writeable which isn't possible to cdrom)"
ECHO " and are simply a record of changes made..."
ECHO " ...deleting them will restore the system to the supplied state, however leaving the"
ECHO " shadow files in C:\TEMP will let you start hercules off the cdrom again with all"
ECHO " changes you have made preserved, until you clean temp at some point anyway :-)"
PAUSE

REM ----------------------------------------
REM Check Windows Version
REM ----------------------------------------
:checkver
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
REM BOTH VISTA AND WIN2008 RETURN 6.0.nnn
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto warn_and_exit

REM -------------------------------------------
REM Windows 7, Vista and XP command section
REM -------------------------------------------
:ver_Win7
:ver_vista
:ver_XP
REM The below should work from WinXP up
SET batpath=%~dp0
PATH=%batpath%hercules-3.05;%batpath%wc3270
ECHO "Starting hardware console"
START "hwcons" /D %batpath%turnkey3 /MIN /SEPARATE /NORMAL hercules.exe -f %config%
REM ECHO "Wait about five seconds then hit enter"
REM pause
ECHO "Starting hardcopy, master console, alternate console and one tso session"
START "hdcopy" /SEPERATE /NORMAL telnet localhost 3270
START "mastcnsl" /SEPARATE /NORMAL wc3270 -allbold localhost:3270
START "altcnsl" /SEPARATE /NORMAL wc3270 -allbold localhost:3270
START "tso1" /SEPARATE /NORMAL wc3270 -allbold localhost:3270
ECHO "-----> Hit enter on the mastcnsl window that prompts for options to start the system <------" ECHO "note: if you have changed system exits before ipl'ing use R00,CLPA instead of enter" ECHO "...and thats it, you are running" ECHO " users available for tso" ECHO " (admin) mark and sysprog, password mvs38j" ECHO " (guest) guest1 thru guest5, password guest" ECHO "Enjoy." goto end REM ------------------------------------------- REM Windows Server 2003, WinXP and Win2000 REM command section REM ------------------------------------------- :ver_2003 :ver_2000 echo "The autorun script is not supported for Windoze Server 2003 or Windows 2000" goto end :warn_and_exit echo Machine OS cannot be determined. :end Note that the above bat file uses a different configuartion file if it detects it is running from a CD/DVD, which as noted earlier has the only differences of moving the location of anything that will be written to (excluding tapes) to C:\TEMP for CD/DVD as obviously that media is unwriteable. I won't show the actual hercules configuration files used here, there is enough info on how to use those on the many hercules sites on the internet; this post is just on how to make it a "live" media image.
A few important notes.

  • while on Win7 pro the autoplay menu appears, on win7 home premium where I have disabled autoplay even a right click
    won't show the hercules option. In which case you will just have to manually click on hercules/autostart.bat to get up
    and running
  • If when the system starts you have a device interrupt on device 009, you either do not have telnet enabled on your PC
    or its a stupid windows thing. If you have telnet enabled start a cmd prompt and "telnet localhost 3270" and the
    interupt will clear (or you can ignore it until the message buffers fill up); on win7 home premium it won't start
    from the autostart.bat file, on Win7 prfessional it will; I don't care thats why I use Linux

But basically thats it. However /hercules/autorun.bat gets triggered you will have a running hercules TK3 system
with three 3270 sessions and (if enabled) a telnet session connected for you to play with.

About mark

At work, been working on Tandems for around 30yrs (programming + sysadmin), plus AIX and Solaris sysadmin also thrown in during the last 20yrs; also about 5yrs on MVS (mainly operations and automation but also smp/e work). At home I have been using linux for decades. Programming background is commercially in TAL/COBOL/SCOBOL/C(Tandem); 370 assembler(MVS); C, perl and shell scripting in *nix; and Microsoft Macro Assembler(windows).
This entry was posted in MVS3.8J. Bookmark the permalink.