private void startAsyncDelete ( ) throws IOException { Runtime rt = Runtime . getRuntime ( ) ; File scriptFile = null ; if ( platformType == SelfExtractUtils . PlatformType_UNIX ) { scriptFile = writeCleanupFile ( SelfExtractUtils . PlatformType_UNIX ) ; rt . exec ( "chmod 750 " + scriptFile . getAbsolutePath ( ) ) ; rt . exec ( "sh -c " + scriptFile . getAbsolutePath ( ) + " &" ) ; } else if ( platformType == SelfExtractUtils . PlatformType_WINDOWS ) { scriptFile = writeCleanupFile ( SelfExtractUtils . PlatformType_WINDOWS ) ; // Note: must redirect output in order for script to run on windows. // This is a quirk validated by testing. Redirect to NUL is fine since we're // not trying to trap this output anyway. rt . exec ( "cmd /k start /B " + scriptFile . getAbsolutePath ( ) + " >/NUL 2>/NUL" ) ; } else if ( platformType == SelfExtractUtils . PlatformType_CYGWIN ) { scriptFile = writeCleanupFile ( SelfExtractUtils . PlatformType_CYGWIN ) ; // convert to Unix type path and run under bash rt . exec ( "bash -c " + scriptFile . getAbsolutePath ( ) . replace ( ' ' , ' ' ) + " &" ) ; } }
Start async deletion using background script