Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noconsole option for Windows? #8

Open
thezeagar opened this issue Jul 18, 2020 · 13 comments
Open

noconsole option for Windows? #8

thezeagar opened this issue Jul 18, 2020 · 13 comments

Comments

@thezeagar
Copy link

Is there a way to run autoadb.exe without the console opening?

I have autoaudb set as a startup process and set to run scrcpy-noconsole.exe when I plug in my phone. That works great, but of course I still end up stuck with the console window open from autoadb running.

Is there any way to just run it in the background, without the console having to stay open, or can you release a noconsole.exe version like you did with scrcpy?

Thank You,
Zeagar

@AdamWHY2K
Copy link

You can use nircmd. Start autoadb with a batch file and use
title YOURTITLE
nircmd.exe win hide ititle "YOURTITLE"
to hide the batch file

@thezeagar
Copy link
Author

Thank you, that worked perfectly

@Dhyfer1
Copy link

Dhyfer1 commented Dec 19, 2021

I have autoaudb set as a startup process and set to run scrcpy-noconsole.exe when I plug in my phone. That works great, but of course I still end up stuck with the console window open from autoadb running.

Is there any way to just run it in the background, without the console having to stay open, or can you release a noconsole.exe version like you did with scrcpy?

Hi. Can you tell me how did you do it? how did you set autoadb as a startup process? I want scrcpy to run at system startup and when I connect my device it automatically runs scrcpy without opening a command line to call autoadb. Is this possible?

@AdamWHY2K
Copy link

To have it run at startup you can make a batch file to start autoadb and place it in AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Running with an invisible command line requires nircmd.

The batch file should look something like

title HideADB
nircmd.exe win hide ititle "HideADB"
autoadb scrcpy -m 600

@Dhyfer1
Copy link

Dhyfer1 commented Dec 21, 2021

Hi @AdamWHY2K I still need some help, I have no experience creating .bat files. To start with, I have done the following:

  1. I have created a new text file and saved it as any_name.bat in the path you mentioned and with the same lines of your example
title HideADB
nircmd.exe win hide ititle "HideADB"
autoadb scrcpy -m 600
  1. As I am using Windows 11 64bits, I have downloaded the 64bit version of NirCmd, then I run the file nircmd.exe and the file indicates if I want to copy the executable to the Windows directory.

image_9

I click on Ok, but then nircmd shows an error message indicating that nircmd could not copy the executable to the Windows directory, so I do it manually. Here I have a doubt, the nircmd file had to be copied to the Windows directory or I had to copy it to the Scrcpy directory?

  1. Since nircmd.exe is in the Windows directory and the batch file is in the path %AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, I restart the computer. After restarting and inside Windows, I connect my phone, but scrcpy does not open, the file explorer opens instead.

What have I done wrong? what is missing here? As I said before, what I want is that every time I login to my PC and connect my phone, scrcpy opens automatically.

@AdamWHY2K
Copy link

Heyo @Dhyfer1

NirCmd just needs be in your %PATH% so moving it to C:\Windows should be sufficient.

But even without NirCmd the autoadb part should've worked, if you edit the .bat file you created to include a pause line, then run it and let me know what the errors are.

@Dhyfer1
Copy link

Dhyfer1 commented Dec 21, 2021

@AdamWHY2K Hi! As I said before, nircmd is in the Windows directory (C:\Windows), so there is no need to add it to %PATH%, except if I change its location.

Well, I have edited the .bat file to include the pause line as you said, I edited it as follows, I hope it is ok:

title HideADB
nircmd.exe win hide ititle "HideADB"
autoadb scrcpy -m 600
pause 

But when I run the .bat file, (even before I add the Pause line), the command window appears with this message:
"autoadb" is not recognized as an internal or external command, program or executable batch file.

Even with the bat file edit and after a system reboot, scrcpy still does not appear automatically when I plug in my phone. :(

@AdamWHY2K
Copy link

It looks like you need to add autoadb and scrcpy to path too

@Dhyfer1
Copy link

Dhyfer1 commented Dec 22, 2021

Hmm. There is something I forgot to mention, when I downloaded nircmd 64bits it downloaded as a zip file, and inside it has 3 files: a help file, and two executables (nircmd.exe and nircmdc.exe), of these last two I only extracted the file nircmd.exe to C:\Windows. The other file, nircmdc.exe also has to be put in that directory?

You say I need to add autoadb and scrcpy to path too. Are you serious? that would mean that I would also have to add all the files that come with scrcpy!? (adb, scrcpy-server, scrcpy-noconsole, scrcpy-console, all his dll files? etc).

It would be easier if you tell me how you have configured your bat file and the directories where you have everything else.

@AdamWHY2K
Copy link

You don't need nircmdc.exe for this.

You can add the folder you installed scrcpy at to path, if you go to Settings > System > About > Advanced system settings > Environment variables > Double click "Path" > Click "New" > Paste your install directory.

SystemPropertiesAdvanced_kSyHJryHab

@Dhyfer1
Copy link

Dhyfer1 commented Dec 23, 2021

Hi buddy! First of all, thank you for your patience, your time and your help. :)

Well, I have done what you say, I have added the scrcpy folder to the system variables and it does work. So the files for scrcpy to work at system startup are in the following paths:

  • The bat file with the same lines of code as in your example is at %AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  • The file nircmd.exe is located at %SystemRoot%
  • The scrcpy folder is in the Downloads folder and as I said before, added to Path in the system variables

When I restarted my computer, and after connecting my phone, scrcpy opened automatically as I wanted, thanks for that. But now I have two questions that I think it will be easy for you to answer:

  1. In the bat file, which means -m 600?
  2. I have scrcpy pinned to the taskbar, and when I click on its icon to open it manually, the scrcpy window and the console window appear.

image_12

My question is, is another bat file needed to hide the console window or does the bat file in your example need to be edited to also hide the console when scrcpy is opened manually?

Thanks. 😊

@AdamWHY2K
Copy link

AdamWHY2K commented Dec 23, 2021

No problem my man :)

-m 600 defines the size of the scrcpy window, you can remove it to mirror the device exactly.

To launch it from the taskbar without a console you need launch it using the same bat file, you can pin the bat file to taskbar by following this guide

@Dhyfer1
Copy link

Dhyfer1 commented Dec 24, 2021

Thank you very much! I did the steps mentioned in the tutorial and it works. I now have a console icon pinned to the taskbar which when clicked opens a console window for a few seconds and then opens scrcpy.

I think that editing the scrcpy-console.bat or scrcpy-noconsole.vbs file (both files come with scrcpy) will achieve the same result, i.e. hide the console window when scrcpy is opened by clicking on its icon in the taskbar, but I don't know how to edit those files. I think I will open a new issue about that later.

That's all, thank you very much for your help my friend, and Merry Christmas.🎄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants