Announcement

Collapse
No announcement yet.

Simple script help

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple script help

    hi guys,

    Wondering if someone could help me out a little please.

    i have a simple batch file which implements a service restart when i run it. What i would like is to move it to the windows startup folder but keep it minimized when running.

    the current script is

    @echo off
    NET STOP TVersityMediaServer
    NET START TVersityMediaServer

    Could someone please tell me what i would need to put in for the window to start minimized

    Hope someone can help

    Cheers

  • #2
    Re: Simple script help

    try this:

    start /min %SYS32%\cmd.exe /c "%fullpathtofile%\%batchfile%"

    Comment


    • #3
      Re: Simple script help

      Very nice XtaZee


      There are also a few other options;

      1. You can create another batch as XtaZee provided. And run your batch from within this batch:
      @start ""/MIN %comspec% /c "path\folder\yourbatch.bat"

      -=OR=-

      2. Add these lines sticked together to the top of your existing batch
      @SET "batchfile=%0"
      @IF NOT [%1]==[MINIMIZED] (
      @start ""/MIN %comspec% /c %batchfile% MINIMIZED %1 %2 %3 %4 %5
      @GoTo:EOF) ELSE (@SHIFT)

      ::(You can still use up to 5 (%5) own command-line parameters to run with your batch, you can change that number if you like)

      3. Or you can Download cmdow.exe to the batch's folder (or to a subfolder of the batch's folder). Add this line to the top of your batch:
      @"%~dp0\subfolder\CMDOW.exe" @ /MIN
      ::(it is even possible with cmdow to completely hide the batch-window, if you use /HID instead of /MIN)



      note,
      Some services will pending for a moment after a STOP (or start) command before it is fully stopped. Your batch is not aware of that and it can happen that it will try to start the service to soon, in that case it returns an error.
      For Stopping and Starting a service you can also use this batch:
      Code:
      ::::::::::::::::::::::::::::::::::::::::::::::::::::
      :: "Stopping and Starting a (remote) Service reliable"
      :: http://forums.petri.com/showthread.php?t=23691
      ::   batch:  SvcRestart.cmd
      ::   author: Remco Simons
      ::::::::::::::::::::::::::::::::::::::::::::::::::::
      
      @echo off
      REM (see text) "%~dp0\subfolder\CMDOW.exe" @ /MIN
      
      Set "_Computer=%computername%"
      Set "_Service=TVersityMediaServer"
      
      :Stop  ------------------------------------
      Sc.exe \\%_Computer% stop "%_Service%" >nul
      :StopPending  -----------------------------
      title STOPPING SERVICE & COLOR 9E
      For /F  "tokens=3 delims=: " %%* In ('sc.exe \\%_Computer% query "%_Service%" ^|Findstr/i "state" ^|Findstr/i ":" ') Do (
          (echo.%%* |Findstr/i "PENDING")&&(Goto:StopPending)||(Goto:Start))
      
      :Start  ------------------------------------
      Sc.exe \\%_Computer% start "%_Service%" >nul
      :StartPending  -----------------------------
      title STARTING SERVICE & COLOR 20
      For /F  "tokens=3 delims=: " %%* In ('sc.exe \\%_Computer% query "%_Service%" ^|Findstr/i "state" ^|Findstr/i ":" ') Do (
          (echo.%%* |Findstr/i "PENDING")&&(Goto:StartPending)||(Goto:Done))
      
      :Done  --------------------------
      \Rems
      Last edited by Rems; 24th May 2008, 23:30. Reason: added the colors

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Simple script help

        Use AutoIT or if you need my help to compile it just say so.

        If you use this code in AutoIT and compile it as a .exe you will see nothing, not even a black command prompt in your taskbar.

        RunWait(@ComSpec & " /c " & 'NET STOP TVersityMediaServer', "", @SW_HIDE)
        RunWait(@ComSpec & " /c " & 'NET START TVersityMediaServer', "", @SW_HIDE)

        RunWait command will execute the NET . . . . command and wait untill the command is finished. @SW_HIDE will hide the screen and in this example the command prompt screen.

        AutoIT can be found on this website: http://www.autoitscript.com/autoit3/downloads.shtml

        This is easy stuff with AutoIT, but you can do alot more with it to make your life easier

        Originally posted by roylee77 View Post
        hi guys,

        Wondering if someone could help me out a little please.

        i have a simple batch file which implements a service restart when i run it. What i would like is to move it to the windows startup folder but keep it minimized when running.

        the current script is

        @echo off
        NET STOP TVersityMediaServer
        NET START TVersityMediaServer

        Could someone please tell me what i would need to put in for the window to start minimized

        Hope someone can help

        Cheers
        Last edited by Iznogoud; 7th May 2008, 22:06.

        Comment


        • #5
          Re: Simple script help

          It is not nessesary to use the RunWait command (AutoIT) or Start/w (batch), because Net Stop does this by it self with the same results.


          \Rems

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment

          Working...
          X