1 /*
2 * Copyright (C) The Spice Group. All rights reserved.
3 *
4 * This software is published under the terms of the Spice
5 * Software License version 1.1, a copy of which has been included
6 * with this distribution in the LICENSE.txt file.
7 *
8 * Portions of this software are based upon software originally
9 * developed as part of the Apache Myrmidon project under
10 * the Apache 1.1 License.
11 */
12 package org.realityforge.nativekit.impl.launchers;
13
14 import java.io.IOException;
15 import org.realityforge.nativekit.ExecException;
16 import org.realityforge.nativekit.ExecMetaData;
17
18 /***
19 * A command launcher for Windows 2000/NT that uses 'cmd.exe' when launching
20 * commands in directories other than the current working directory.
21 *
22 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
23 * @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
24 * @version $Revision: 1.1 $ $Date: 2003/04/16 10:31:49 $
25 */
26 public final class WinNTCommandLauncher
27 implements CommandLauncher
28 {
29 /***
30 * Launches the given command in a new process using cmd.exe to
31 * set the working directory.
32 */
33 public Process exec( final ExecMetaData metaData )
34 throws IOException, ExecException
35 {
36 // Use cmd.exe to change to the specified directory before running
37 // the command
38 final String[] prefix = new String[ 6 ];
39 prefix[ 0 ] = "cmd";
40 prefix[ 1 ] = "/c";
41 prefix[ 2 ] = "cd";
42 prefix[ 3 ] = "/d";
43 prefix[ 4 ] = metaData.getWorkingDirectory().getCanonicalPath();
44 prefix[ 5 ] = "&&";
45
46 final ExecMetaData newMetaData = ExecUtil.prepend( metaData, prefix );
47 final String[] env = ExecUtil.getEnvironmentSpec( metaData );
48 return Runtime.getRuntime().exec( newMetaData.getCommand(), env );
49 }
50 }
This page was automatically generated by Maven