So I created this program to launch overwatch and chrome when i open it.
#echo off
start Overwatch.exe
start Chrome.exe www.youtube.com
timeout 2 > exit
Can I somehow make it run automatically after turning on my pc?
Here's the site you might want to look at:
https://www.computerhope.com/issues/ch000322.htm
Basically you want
Run a batch file at boot in Windows 8 and 10 users
Create a shortcut to the batch file.
Once the shortcut has been created, right-click the file and select Cut.
Press the Start button and type Run and press enter.
In the Run window, type shell:startup to open the Startup folder.
Once the Startup folder has been opened, click the Home tab at the top of the folder and select Paste to paste the shortcut into the folder.
Related
I wrote a batch file with the intention of launching Opera and VSCode (on a workspace) with one click, it looks like this:
It runs just fine. Opera starts, then VSCode does as well. The problem is, that when I close the CMD window, VSCode also shuts itself down. I wanted the CMD window to automatically close after execution in the first place, so I tried putting an "&& exit" and "exit" at the end of the code (not at the same time), but it didn't work.
I assume that you have opera.exe added to the PATH.
#echo off
start opera
cd C:\Users\louis\Desktop\Development\Projects\JS
"C:\Program Files\Microsoft VS Code\bin\code.cmd" JS.code-workspace
or
#echo off
start opera
"C:\Program Files\Microsoft VS Code\bin\code.cmd" C:\Users\louis\Desktop\Development\Projects\JS\JS.code-workspace
I have a simple one-line batch script to map a network drive drive. I'd like to place this in the startup folder so that I have the drive available whenever I turn my computer on.
The file looks like this:
#echo off
pushd \\path.to.network\drive
When I open up command prompt and run map_drive.bat, it works as intended and I am now able to access my drive. However, when I double click on the file or place it in the startup folder and turn my machine on, nothing happens.
]I've tried running as an administrator, putting the network path in quotes, and adding a "pushd %~dp0" line to the start of the file, but none of these so far have made a difference.
When trying to open vscode folder using a batch file, Visual Studio opens up with that folder, but also a cmd window pops up and does not go away if you use exit command.
#echo off
start code "C:\GitHub\TestApp\testapp"
exit
VSCode opens up correctly, but also this window opens
Using VSCode 1.52.1, the only way I could start it without having a cmd window open after exiting the batch script is:
explorer.exe "%userprofile%\AppData\Local\Programs\Microsoft VS Code\Code.exe"
Note: it does not involve opening a specific local directory to work with. But maybe you can find a solution such as saving the folder as a workspace or using Ctrl+R to open recent folders. Plus, if you work only within that directory / workspace, or use it right before closing VSCode, it will be opened automatically at the next launch.
That's because you are actually invoking the batch file code.cmd which is located at [VSCodePath]\bin\code.cmd. The code.cmd file in turn invokes the actual VSCode executable code.exe
When invoking a batch file (.BAT or .CMD) using the start command, a new instance of CMD process will be created to handle the execution of the batch file, But it invokes the CMD process with the /K switch rather than /C
For example start code.cmd executes cmd /k code.cmd
It is the /K switch that causes the new cmd to remain open after finishing the execution of the batch file.
To resolve, instead of supplying the batch file directly the to the start command, execute it by an explicit CMD invokation:
#echo off
start cmd /C code "C:\GitHub\TestApp\testapp"
exit
That CMD window is associated with the VSCode instance that you just opened. Attempting to close it will terminate the application you started. (in this case, VSCode)
The start xxx xxx... command opens up a new cmd terminal to perform its action. Even though a new prompt appears, which can be used as a normal terminal itself, the VSCode process is inexorably linked to it as the parent process.
If your goal is to not launch a separate cmd window, then run:
start code /b "C:\GitHub\TestApp\testapp"
which just runs the command in the same window. The VSCode window is still inexorably bound to the current cmd window and will close if the cmd window disappears, but at least another cmd window isn't launched.
Windows doesn't have the capability to launch a program in the background from the terminal.
If all described solutions did not work for you, try making an ordinary Windows shortcut to "C:\Users\username\AppData\Local\Programs\Microsoft VS Code\Code.exe" C:\path-to-project-folder-or-file.
Then call this shortcut in your .bat or .cmd script like that (assuming shortcut name is shortcut):
#echo off
start C:\path-to-shortcut-file\shortcut
I'm attempting to write a batch file that will move to the specified directory and then run the command to open my desired program. Specifically I want it to run the command HardwareSimulator so it will open the software nand2tetris provides.
I've gotten it to move to the directory I want, but the opening is my issue. Code is displayed below. I'm guessing start isn't the correct command since when I run, it just runs an infinite loop of opening cmd prompts.
My second question would be: can I only go into sub-directories of where my batch file is already stored? It would be easier to store it in my desktop, so I can just click it whenever, but I can't seem to make it back out of a directory and then go down into another.
start cmd
pushd \nand2tetris\projects\P1Codes
start HardwareSimulator
pause
You can use ..\ to go back a directory.
For instance, if you had nand2tetris in your downloads folder you could get to it from the desktop with this script. Also make sure to to include the file extension.
pushd ..\Downloads\nand2tetris\projects\P1Codes
start HardwareSimulator.exe
pause
i am trying to start up a series of .exe's (minecraft console client)
with only 1 click but when i setup an .bat file it opens it in the folder where the .bat is placed not where the .exe is and all the info files are where the .exe is, i would just move them but all the info files are called the same things with diffrent info and the .exe is encrypted (so nobody can take code, i think its called encrypted idk).
How I want it to load: http://gyazo.com/a451735cb34262bf1bfc0709e7d6a11c
How it actually loads: http://gyazo.com/4ed35f560c41370d9d33f865fc67fccf
The .bat: START C:\Users\Fergal\Desktop\ConsoleClient\Vortex\Pinshi_Bwub\MinecraftClient.exe -Would have used another gyazo but don't have enough rep :(
Try the following batch file:
cd C:\Users\Fergal\Desktop\ConsoleClient\Vortex\Pinshi_Bwub
start MinecraftClient.exe