I am trying to code a batch file that can play a song.
Luckily I found a solution to that at Stack Overflow. I used SachaDee's method, which created a VBS file that would play my mp3 file nicely.
My only issue is that once the VBS file is opened, I can't seem to find a way to stop the music. I even tried deleting the file in mid-song, but the song will still continue.
EDIT:
I found out that the way to solve this is by running the following command.
taskkill /IM wscript.exe /F
Just to end up the question.
taskkill /IM wscript.exe /F
This will stop wscript.exe with full force. However, a vbs can also be executed through cscript.exe.
According to this question, it seems to be ideal to use cscript for command-line, to execute VBS. Altough both works.
With your keyboard, press Ctrl+alt+del , then click Task Manager.
In task manager, click on the section where it shows you the programs that are running.
Find the VBS icon: A little cube with branches.
Click on the icon, then on the End Task Button.
Related
My Mail App for Windows 10 starts lagging like CRAZY with 4 second reaction times for each click. (yeah) When that happens I simply have to restart it to fix the issue. (No one has been able to understand why This happens when mail-app is idle)
I just thought I make a simple batch file who kills the app and restarts it each time I wanna open it so it always opens fresh. (Killing it takes just a second extra)
I managed to find that the name of the mail app process was HxOutlook.exe so I wrote this successful code
taskkill /IM HxOutlook.exe /F
But when trying to boot the process I cannot find out how. I tried the file directly but I get acces denied. Tried running is as my user which is admin, still same error. When trying to run as 'admin' it always says wrong password. However I don't want to have to enter password..
I found the HwOutlook folder and tried Using this code to call .exe:
runas /user:Administrator "C:\Program Files\WindowsApps\microsoft.windowscommunicationsapps_16005.11029.20108.0_x64__8wekyb3d8bbwe\HxOutlook.exe"
I also created a shortcut from the start menu and it says it executes microsoft.windowscommunicationsapps_8wekyb3. But trying to do that gets only error is not recognized as command or program
What can I add to the batch script to make it open the app again as if I click a shortcut like I can do in start, desktop and taskbar...
Just calling the shortcut from the desktop like Mail.lnk solved it for now.
taskkill /IM HxOutlook.exe /F
Mail.lnk
Sorry for the awfully worded title, I have a batch file that runs the command:
"taskkill.exe /F /FI "status eq NOT RESPONDING"
I then attached a shortcut of the file to my task bar so that whenever a program doesn't respond I have quick access to close it.
However, recently it has decided to start closing Discord, despite it responding normally at pretty much all times. I'm not sure why, can anyone help?
Apply a taskkill filter for WINDOWTITLE or IMAGENAME and use the not equal (ne) operator to exclude Discord.
Discord could be not responding at the moment you are running your script.
Trying to create a batch file that will open a specific browser (firefox) minimized and direct it to a link. After A specific period 5 seconds the browser will close. I can direct to the link open a specific browser but the browser does not start minimized nor does it close after 5.
#echo off
SET BROWSER=firefox.exe
SET WAIT_TIME=2
start /min %BROWSER% http://www.stackoverflow.com
SET WAIT_TIME=2
taskkill /IM firefox.exe
Your batch file cannot close the process because, while it sets a variable called WAIT_TIME, the batch file does not actually wait; the taskkill command runs immediately, before the process has even started. You need to add a command such as timeout to actually make the batch file wait.
SET WAIT_TIME=2
timeout %WAIT_TIME%
taskkill /im firefox.exe
For the minimized window, there is no good solution. A Windows (non-console) program receives the /min param through its nCmdShow parameter to WinMain(), but it's up to the program what to do with that. Most simply ignore it. There are 3rd-party solutions which will send a minimize command to the window after it has opened, but there's no easy way to do this in Windows Batch without involving another scripting language like VBS or PowerShell.
I am trying to write a simple batch file that will use the 3rd option from a context menu of a .wmv file
I made a hack on my computer to play videos as the back ground but because it is a hack when I restart my computer I have to restart the video by right clicking on it and selecting set as desktop background. I just want to make a simply batch file, and put it in my start up file, that will do this for me but I am having trouble writing the code.
I can't use start application name "over.wmv" because I'm not really running an application
Thank you in advance for any and all help.
I don't have your "hack" to play videos, so I can't test this, but I think what that menu option does is something like this :
reg.exe add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "C:\path\over.wmv"
rundll32.exe user32.dll,UpdatePerUserSystemParameters
Before I get comments saying this is a duplicate, I looked, found similar questions but their respective answers didn't work for me.
I currently have a simple batch script to refresh explorer.exe (related to this question) and have exit at the end. The script works but the command window doesn't close. Looking at other questions, people had suggested using exit/b. Tried that as well and it had the same affect as the former.
My full code can be found in the link above but I will also post here.
#echo off
cls
taskkill /f /im explorer.exe >nul
timeout 1 /nobreak >nul
explorer.exe
exit
Use start explorer.exe so that explorer is launched on its own thread and not using the command window thread. As it is now, by just calling the application from the script, you are telling the command window to wait until explorer is exited before continuing.