/**
* setup.cpp :
* invokes corresponding replicatorreceivercd?.jnlp file when invoked from a CD
* setup.exe usually trigged by autorun.inf
* Need a different version depending on which drive letter is the CD ROM drive.
* For windows only.
*
* Copyright: (c) 2003-2017 Roedy Green, Canadian Mind Products
* #101 - 2536 Wark Street
* Victoria, BC Canada V8T 4G8
* tel:(250) 361-9093
* http://mindprod.com
*/
#include "stdafx.h"
#include <direct.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char* jnlpBaseName = "replicatorreceivercd";
/**
* Invoke JNLP file corresponding to drive letter
* running from.
*
* @param argc not used
* @param argv not used
*
* @return system error code
*/
int main( int argc, char* argv[] )
{
char curDrive = 'A' + _getdrive() - 1;
int baseLength = strlen( jnlpBaseName );
char* jnlpName = new char[ baseLength + 7];
strcpy( jnlpName, jnlpBaseName );
jnlpName[ baseLength ] = curDrive;
jnlpName[ baseLength + 1 ] = 0;
strcat ( jnlpName, ".jnlp" );
char* shell = getenv( "ComSpec" );
if ( shell == NULL )
{
shell = "cmd.exe";
}
printf( "Installing %s with Java Web Start via the %s shell.\n", jnlpName, shell );
if ( _spawnlp( _P_OVERLAY, shell, shell, "/C", jnlpName, NULL ) )
{
printf ( "Java Web Start, part of the Java JRE, must be installed first. Error %u\n", errno );
}
delete jnlpName;
return 0;
}