locked
Hide or minimize cmd window when run a script RRS feed

  • Question

  • Hi all,

    I am tring to hide or at least minimize the cmd window when running this script

    "cmd start /min /c ipconfig/all > c:\MacAddress.Txt"

    I try to put this script in windows run but i still get the cmd window come in front of me.

    Is there any way to hide this or at startup keep the cmd window minimized,

     

    Thanks all,

    Sunday, November 13, 2011 6:22 PM

Answers

  • If I understand the OPs description right (which is far from certain), the problem with this approach is that the c:\Tools\MyScript.vbs script cannot be expected to exist on the user's machine.  Therefore, this approach is not likely to satisfy the need.  In fact, I am surprised about the purported capability to run any client side application via this P_1_Host('') process.  It sure seems like a gaping security hole to me.  It is a fundamental internet tenant that a web author is prohibited from doing such things without user interaction/acceptance/approval in some form or other.

    In the past, START was a stand alone application which could be used to do this, but it was changed to an intrinsic command in the command processor in recent Windows OSs (probably for the very reason that it presented a security hole).  Assuming the 'host' process exists and works as claimed, it would therefore appear to me that it needs to provide the capability to control the window it instantiates or the desired behavior is impossible. 


    Tom Lavedas
    Monday, November 14, 2011 2:07 PM

All replies

  • Here you go:

    Set oWshShell = CreateObject("WScript.Shell")
    oWshShell.Run "cmd.exe /c ipconfig.exe /all > d:\MacAddress.Txt", 0, True

    Sunday, November 13, 2011 6:32 PM
  • Hi,

    So i have to create object then i have to pass this parameter.

    But from my program i am using one procedure called HOST("Cmd parameter") which allow you add parameter how i can implement the above in my case

    By the way, i copy the above script and put in cmd ,the first line working fine ,but the second give me an error

    'oWshShell.Run' is not recognized as an internal or external command,

    Thanks,

    Sunday, November 13, 2011 7:06 PM
  • I gave you a VB Script solution, which means that you have to save it not as a .bat file but as a .vbs file.

    It is not clear from your reply where the "host" parameter should be used with ipconfig.exe.

    Sunday, November 13, 2011 7:29 PM
  • Ok let review my sceniro again ,

    I have a web application which requrie to collect client mac address , So the developer tool just give one option which is create a txt file then read the mac address from this file.

    I have one procedure call P_1_Host(''); which allow you to run any application like cmd.exe but when i run this command "cmd start /min /c ipconfig/all > c:\MacAddress.Txt" using my Procedure the cmd window come in front of me , my question is there any way i can hide this window or at least when it's start keep it minimize until the script finish.

     

    Thanks for help, 

     

    Monday, November 14, 2011 3:41 AM
  • Instead of running
    "cmd start /min /c ipconfig/all > c:\MacAddress.Txt"
    you run
    "wscript c:\Tools\MyScript.vbs"
    where c:\Tools\MyScript.vbs is the script I gave you in my first response.
    Monday, November 14, 2011 7:11 AM
  • If I understand the OPs description right (which is far from certain), the problem with this approach is that the c:\Tools\MyScript.vbs script cannot be expected to exist on the user's machine.  Therefore, this approach is not likely to satisfy the need.  In fact, I am surprised about the purported capability to run any client side application via this P_1_Host('') process.  It sure seems like a gaping security hole to me.  It is a fundamental internet tenant that a web author is prohibited from doing such things without user interaction/acceptance/approval in some form or other.

    In the past, START was a stand alone application which could be used to do this, but it was changed to an intrinsic command in the command processor in recent Windows OSs (probably for the very reason that it presented a security hole).  Assuming the 'host' process exists and works as claimed, it would therefore appear to me that it needs to provide the capability to control the window it instantiates or the desired behavior is impossible. 


    Tom Lavedas
    Monday, November 14, 2011 2:07 PM