Open command prompt via applet?

Hi guys
I am expecting this code to open a command prompt on the user's PC. I have the same "cmd.exe /k" in a test.bat file which does what I expect. This code, however, doesnt seem to be opening a command prompt, but the applet is launching fine. Any ideas?
Thanks in advance.
import java.applet.*;
import java.awt.*;
import java.io.IOException;
public class MyApplet extends Applet {     
     private static final long serialVersionUID = 1L;
     public void init() {
          setBackground(Color.WHITE);
     public void start()  {
          try {
               openCMD();
          } catch (IOException e) {}
     public void stop() {
     public void paint(Graphics g) {
          g.drawString("Applet Started", 10, 10);
     public void openCMD() throws IOException {
          System.out.println("opening cmd..");
          Runtime.getRuntime().exec("cmd.exe /k");          
}

Hi, that code for opening the cmd through n applet is great and works perfectly....
Does anyone know how to then enter a filename into this code, which will open the cmd, and then open another file?
I have the following code:
String[] cmd = new String[6];
cmd[0] = "cmd.exe";
cmd[1] = "/C";
cmd[2] = "start";
cmd[3] = "cd";
cmd[4] = "C:\\path";
cmd[5] = "javaw";
cmd[6] = "FileName";
Process process = Runtime.getRuntime().exec( cmd );
But this does not seem to work at all. if i delete cmd[5] and cmd[6] it works and opns up the cmd with the specified path, but i cannot get it to open the java file or any file for that matter.
Any help would be great!

Similar Messages

  • Reading newly opened command prompt output

    I need to use SSH to connect to a server. Rather than downloading a third party SSH API, I would like to use Putty which is already on my computer. The problem is that when using Putty from the command line to connect to a server it opens the connection in a completely different command prompt window instead of the original window. How would I read the output from the new window? I believe this code would have worked if it opened the connection in the same command prompt window...
    try{
    File test = new File("c:\\program files\\putty");
    Runtime rt = Runtime.getRuntime();
    Process output = rt.exec("cmd /c putty.exe -ssh username@host", null, test);
    BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));
    String line = null;
    while((line = br.readLine()) != null )
    { System.out.println(line); } // display process output
    int exitVal = output.waitFor(); // get process exit value
    System.out.println("Process Exit Value : "+ exitVal);
    catch(IOException ioe){
    System.err.println(ioe);
    catch (Throwable t) {
    t.printStackTrace();
    }

    web definition of 'come unstuck' :
    come unstuck (British & Australian)
    if a person or something they are trying to achieve comes unstuck, they have problems which cause them to fail. Athletes who don't prepare properly for the humid conditions will certainly come unstuck. The negotiations came unstuck over disagreements about the wording.

  • Host command, change directory where it opens command prompt

    I'm using the HOST command to host out to the command prompt. What I want to know is how to change the directory that the command prompt opens up at. I want it to open up at the c:\ but instead it's opening up at in the forms60 path where forms is installed.
    Thanks in advance

    Hi Viktor,
         What i could understand from your question is that in the FTP server you'll be writing a file in folder A and once the writing is done you need to get it moved to Folder B using a 'CD' OS command. But this OS command is not allowed in the FTP server.
        If that is the case then it will be better to write the file directly into the Folder B. But in the file adapter use the option 'Use Temporary File'. In that case until and unless the file is written fully the file will be having the name .tmp or so.
        The advantage will be the third party server could be polling the folder B for a file *.txt in that case it won't pick this .tmp file.
    Cheers
    JK
    PS: Award points if this helps you.

  • Command prompt is not opening

    Hi,
    i tried to open 'COMMAND PROMPT'. but not able to open. what is the problem and where should i need to change the settings for command prompt.
    Regards,
    venkat.

    I'm going to assume you are on Windoze and are talking about a Windows Command prompt. If so, click on the Start button, then click on Run and type cmd and then click OK.

  • Sound problem and command prompt problem

    hi
    My new cq40 610tu compaq laptop works with only left side speaker is it build with only one left side speaker?  Is there no dual speaker?  But with head phone two headphone speaker works properly.  tell me details.
    another problem when we open command prompt in winxpSP2 it is not stable after few seconds it turns off automatically.  When I type large things in ms word 2003 cursor goes different place automatically.  whats the problem? 
    I purchase this laptop just 15 days ago.  What's the solutions?
    thanks
    Dhiman

    Hi kbzone,
    ... there should difinitely be no sparks  ) I recommend that you start with checking the wiring ... is the computer connected to earth, is the amplifier? Are they connected via the same power socket? Are you sure that the amplifier is OK?
    Then, will it be possible to have any sound from the card if the amplifier is not used? You can try removing cards, uninstalling drivers and then re-install ...
    It is well possible that by now you have damaged your soundcard, btw
    Hans

  • Open a command window and send some keystroke to the opened command window

    Hi All,
    I am trying to open command prompt and send some key stroke to that command prompt. Here I am using Robot to send keystroke. But the problem is, the keystrokes are not sent to the prompt. I guess I need to activate progamitically the command prompt to accept the keystrokes . Please find the code below ( as I did).
    try
    String command = "cmd.exe /c start";
    Process child = Runtime.getRuntime().exec(command);
    Robot robot = new Robot();
    Thread.sleep(5000);
    String lol = "indranil";
    for(int i=0;i<lol.length();i++)
    robot.keyPress(lol.charAt(i));
    int g = lol.length() - 1;
    robot.keyRelease(lol.charAt(g));
    catch (Exception e) {}
    I guess I am doing some mistake here while sending the keystroke/openning the command prompt. Can anyone please help me how can I open a command window and send some keystroke to the opened command window. I am in fix.
    Thanks,
    Indranil

    The first thing to do is read the API and examples for the Robot class.
    Also check out this thread with a similar discussion: [http://forums.sun.com/thread.jspa?threadID=5385677]
    The short spoonfed answer - keyPress() and keyReleaseI() do not take chars. Read up on KeyEvent

  • Running multiple commands in command prompt

    Hi
    I am having the following scenario
    open command prompt
    open xilinx command prompt
    switch to xmd console
    run a set of commands
    print the final output to screen
    I am having the following doubts
    Can system exec.vi take multiple commands as standard input?
    If yes what is the delimiter?
    If no what other options I have to achieve my goal
    Thanks

    Why not write a batch file and start that with System Exec?
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to get the drive letter of a Volume using command prompt

    Using windows command line tools i want to get the drive letter of a volume, by specifying its volume number.
    For example i have a HDD with 2 volumes: Volume-0 and Volume-1
    I want to set a Variable say 'Letter'=<Drive Letter> such as
    SET Letter=<Command> <Volume Number>
    Is there any command which can do this for me...
    Thanks...

    Hi,
    You can use the diskpart tool to assign a drive letter to the drive by specifying the volume's number.
    1.Open Command Prompt.
    2.Type:diskpart
    3.At the DISKPART prompt, type:list volume
    Make note of the number of the simple volume whose drive letter you want to assign, change, or remove.
    4.At the DISKPART prompt, type:select volume n
    Select the volume, where n is the volume's number, whose drive letter you want to assign, change, or remove.
    5.At the DISKPART prompt, type one of the following:assign letter=L
    Where L is the drive letter you want to assign or change.
    For more detailed information, you could refer to the article below:
    Assign, change, or remove a drive letter
    https://technet.microsoft.com/en-us/library/cc757491(v=ws.10).aspx
    Best Regards,
    Mandy 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • I Need Help Adjusting Command Prompt Directories

    I have the satellite L505D---S5983 and I need to change my prompt from C:\Users\Brandon>. I have tried every search I can think of but nothing is working for me. Please help. I need this to be fixed ASAP, I am a app developer for android and I need to get back up and running.

    Satellite L505D-S5983  
    I need to change my prompt from C:\Users\Brandon>.
    Brandon, make a shortcut to cmd (%systemroot%\system32\cmd.exe) and name it Command Prompt.
    Right-click the shortcut, click Properties, and put the folder you want (c:\, for instance) in the Start in: field on the Shortcut tab.
    I find it's a good idea to open command prompts in elevated mode. To do that, click the Advanced button on the same tab and set Run as administrator.
    -Jerry

  • Command Prompt Blue Screen in Windows 10

    McAfee 8.8i isn't supported yet until patch 6 which is due mid-end of this month eitherNod32 V5 seems to work ok though - although I don't know the official stance on that.http://www.bitdefender.co.uk/support/is-bitdefender-2015-compatible-with-windows-10-1451.htmlAlso worth reading if you're not already awarehttp://community.spiceworks.com/topic/1099226-antivirus-maker-bitdefender-hacked-customer-data-sold-...

    Hello All,
    I recently upgraded to Windows 10 and notice that when opening up command prompt, typing in command, then closing by clicking on the X button to close the Window, it will immediately blue screen. When I open command prompt, do a command, then type "exit" in command line, it closes the window with no problem. I haven't see any Microsoft forum reporting any issues so wasn't sure if this is a mass issue that will be rolling in soon or just isolated to my computer.
    Any advice would be helpful.
    This topic first appeared in the Spiceworks Community

  • The main part of the safari page is grey and won't respond/can't type in any commands.  I can move back through the previous pages, and even open new ones via the URL, but can't get onto the main part of the page and I can't get onto the 9 page option. !?

    The main part of the safari page is grey and won't respond/can't type in any commands.  I can move back through the previous pages, and even open new ones via the URL, but can't get onto the main part of the page and I can't get onto the 9 page option. !?
    Help, please.

    Try clearing Safari's cache : Settings > Safari > Clear Cache (and Clear History)
    If that doesn't work then try closing Safari completely and then re-open it : from the home screen (i.e. not with Safari 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Safari app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    A third option is a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • When I open firefox (note: I got firefox version 28.0 and Karspersky security 2014) I get a black screen, looking like a command prompt window, in firefox.

    Hi,
    When I open firefox (note: I got firefox version 28.0 and Karspersky security 2014) I get a black screen covering the whole firefox window and it looks more lika a big command prompt window, in firefox. What is it?
    Regards
    Jean

    Huh, that's a new one...
    Can you try Firefox in [[Safe Mode | Safe Mode]] to see if the problem goes away. I'm thinking it's an extension.
    *Run ''firefox.exe -safe-mode'' in the search bar on the Start Menu. (Make sure Firefox is closed)
    Have you added any new extensions recently around the time this started happening? Your system details shows the following:
    *Adobe Acrobat - Create PDF 1.2 ([email protected])
    *Anti-Banner 14.0.0.4917 ([email protected])
    *Dangerous Websites Blocker 14.0.0.4917 ([email protected])
    *Kaspersky URL Advisor 14.0.0.4917 ([email protected])
    *Troubleshooter 1.1a ([email protected]) '''This is default so this isn't the problem.'''
    * Virtual Keyboard 14.0.0.4917 ([email protected])

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • How do i get a output in CSV of a SQL query executed via SQL Command prompt

    Hi All,
    I have a question with reference to SQL command prompt. I have a sql query which runs properly and gives proper execution in SQL Management console in GUI.
    This report is used to pull the free disk space report of our servers
    As i want to schedule it as a report so i want to script it to run via SQL command prompt. I made the script and it works fine if i enter it in SQL command prompt. When i try to extract the output to a CSV File it fails. Below is the details of the command
    i am using to query to pull the data. Can anyone help me in getting the output of this query in SQL command prompt.
    sqlcmd -W -s , -S Servers FQDN
    use operationsmanager
    Go
    Query:"select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv"
    Go
    When i enter the command without the quotes when the query is starting and ending and also without the output command (-s "," -o "C:\DataSqlCmd.csv") it is working and shows the output in the command prompt. Below is the screen shot for
    your reference.
    Due to security reasons i have to erase the server names:
    But when i add the line to extract the output ( -s "," -o "C:\DataSqlCmd.csv") It gives me this error:
    The exact command would be:
    sqlcmd -W -s , -S CINMLVSCOM01.e2klab.ge.com
    use operationsmanager
    Go
    "select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "C:\DataSqlCmd.csv" -h-1
    Go
    saying the syntax is not correct or some thing as per the below screenshot.
    Can any one please help. Below is just the query whi i use to get the output in SQL management studio.
    Can any one make a command for the below quer so i can directly execute and test for getting the output.
    select Path, InstanceName, SampleValue 
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    Gautam.75801

    Can you try the below query?
    select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < 20 and CounterName like '% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled
    -- replace the below query part in the below SQLCMD C:\>SQLCMD -S SERVERNAME -E -d operationsmanager -Q "select * from sys.databases ds with (nolock) where name='master'" -s "," -o "F:\PowerSQL\MyData.csv" -h -1
    SQLCMD -S SERVERNAME -E -d OperationsManager -Q "select Path, InstanceName, SampleValue
    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid
    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId
    where SampleValue < '20' and CounterName='% Free Space' and TimeSampled > '2014-08-06 11:00:00.00'
    order by countername, timesampled" -s "," -o "c:\MyData.csv" -h -1
    Refer for the other ways 
    http://dba.stackexchange.com/questions/23566/writing-select-result-to-a-csv-file
    --Prashanth

  • HELP FOR RUN PHOTOSHOP IN COMMAND PROMPT AND OPEN FILE

    HELLO
    i have problem for run photoshop in cmd(command prompt) and
    open a file immediate
    for example:
    D:\Program Files\Adobe\Photoshop CS>Photoshop.exe -open -f:\1.jpg
    but these not answer
    I need parameter open in photoshop
    please help me
    thanks

    I would right click on 1.jpg. Select Open with... Select Choose default program... Pick Photoshop and make sure you check "always use the selected program to open this kind of file."
    D:\1.jpg
    Would then open photoshop.

Maybe you are looking for

  • Issue with Disabling one of the menu item in Forms6i

    Hi, I have a requirement where I need to disable the IR/PO Information (menu item) created using Form Personalization in Sales Order form. If the Warehouse is other than 'FIM' it should be disabled for that particular line. Please let me know if anyb

  • Photoshop CC unable to open

    There was an update a few days ago for Photoshop CC which I downloaded. The update failed and now I cannot open Photoshop. What should I do?

  • Can a keyboard shortcut template for CS4 be used with LightRoom?

    Hi, I was just wondering how far off a KB covers keyboard cover/shortcut template made for PhotoShop would be when used with LR2?

  • Make Sure Only Black Ink is Used?

    Hello folks, first time posting here so bear with me. Just bought a Laserjet Pro 400 M451nw and am using it on a Mac with Yosemite (even though the driver I installed said it was for Mavericks, it installed ok and is up and running though), my questi

  • Can't burn some files with DVD studio pro...Makes no sense to me

    I'm sure this problem is a result of me not having understanding of video compression, or codec, or something like that, but I am beyond frustrated with this program at the moment. For some reason I DVD studio will not recognize certain videos. Examp