Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help needed with this batch file  (Read 9623 times)

0 Members and 1 Guest are viewing this topic.

Mnp01

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Windows 7
    Help needed with this batch file
    « on: May 19, 2020, 01:56:13 PM »
    Firstly I want to make it clear that I have no experience in this. Using Win 7 x64. I'm playing a game and somehow another program called Netlimiter is interfering with the game's online. With some experimentation, I figured out that if I close Netlimiter before starting the game, then start the game, then start that program again by Alt+Tab-ing to the desktop -- then the game runs fine.

    After this discovery, the next thing that came to my mind was to have a batch script that could do it automatically and save me the hassle. But as I said, I have no experience in batch scripts or even DOS commands. I have been searching the web for almost a day and came up myself with this script that seems to work. I have put the batch file in the game folder.

    Code: [Select]
    @echo off

    Taskkill /F /IM NLClientApp.exe

    start Monopoly.exe

    TIMEOUT /T 10 /NOBREAK

    start /d "C:\Program Files\Locktime Software\NetLimiter 4\" NLClientApp.exe

    But then there is one annoyance. When Netlimiter starts again(in system tray), it switches my game back to the desktop and then I have to manually click on the game window to go back into the game. Is there any way the above script can be modified so that either this can be prevented, or maybe switch the focus back to the game automatically?

    I'd really appreciate any help. I hope I have explained this well enough.

    nil

    • Global Moderator


    • Intermediate
    • Thanked: 15
      • Experience: Experienced
      • OS: Linux variant
      Re: Help needed with this batch file
      « Reply #1 on: May 19, 2020, 05:25:24 PM »
      I don't know of any way to execute a batch file without it taking application focus.

      However you might be able to do it with VBScript. See this thread for info that might help.

      Do not communicate by sharing memory; instead, share memory by communicating.

      --Effective Go

      Mnp01

        Topic Starter


        Newbie

        • Experience: Familiar
        • OS: Windows 7
        Re: Help needed with this batch file
        « Reply #2 on: May 19, 2020, 08:11:12 PM »
        I don't know of any way to execute a batch file without it taking application focus.

        However you might be able to do it with VBScript. See this thread for info that might help.
        No, actually it's not the batch file taking focus. As you can see that I'm using it to run the game as well, thus it automatically switches to the game window. The issue is that in the last line where Netlimiter starts again in the system tray, my game window minimizes to desktop for whatever reason. I read that it only takes app focus if the app has a window which isn't the case here, so Idk why it's happening. But anyway, if somehow the focus could be brought back to the game, then that's all I'm looking for.
        « Last Edit: May 19, 2020, 08:55:29 PM by Mnp01 »

        nil

        • Global Moderator


        • Intermediate
        • Thanked: 15
          • Experience: Experienced
          • OS: Linux variant
          Re: Help needed with this batch file
          « Reply #3 on: May 20, 2020, 06:29:41 AM »
          Sorry, what I meant was, I don't know of any way to start a program from the command line (or a batch file) which can specify that the new program should not take focus.

          However, VBS allows you to do that. So if you refactor your batch file as a VBScript, it might do what you want.

          Ultimately however the application is going to decide whether it's focused or not. If there's code in Netlimiter that specifically takes control of application focus, you're probably just gonna have to live with it.
          Do not communicate by sharing memory; instead, share memory by communicating.

          --Effective Go