Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Need help with a couple of batch files on Windows 8.1


  • Please log in to reply
13 replies to this topic

#1 Dark Magician Girl

Dark Magician Girl

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 22 April 2014 - 03:54 PM

This is one of the batch files that I have.

 

------------------------------------------------------------------------------------------------------------------------------

start /d "C:\Portable Programs\PaleMoon" palemoon-portable.exe
TIMEOUT 6
start /d "C:\Portable Programs\FreeDownloadManagerPortable" FreeDownloadManagerPortable.exe

------------------------------------------------------------------------------------------------------------------------------

 

- Can I start the command prompt minimized or have it not open at all?

 

- Can I start a program minimized?

 

- Can I start a program without a splash screen?

 

- Can I make a program a leader so that the other programs that are started using the same batch file are automatically closed when the leader program is closed? I'm wondering whether I can have Free Download Manager automatically close when PaleMoon is closed.

 

 

This is another batch file that I have.

 

-------------------------------------------------------------------------

start /d "C:\Program Files (x86)\KCP\MPC-HC" mpc-hc.exe
start /d E:\Documents Anime (Watching).et

-------------------------------------------------------------------------

 

"Anime (Watching).et" is the document I want the batch file to open. However, I'm not sure how to get the batch file to open the document when the document has spaces in its name. I've tried a few different things to no avail.



BC AdBot (Login to Remove)

 


#2 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 30 April 2014 - 05:55 AM

I still need help with this. I'm also looking for a way to write a batch file that will close all running applications and ask me to save work where applicable. Not services and background process; only applications.



#3 Kilroy

Kilroy

  • BC Advisor
  • 3,408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:06:59 PM

Posted 30 April 2014 - 10:59 AM

I haven't tried this - Start minimized

 

For starting the program without the splash that would be a switch or setting used when launching the program.

 

If you're opening a file normally it goes at the end of the program launch.  Try the code below and see if that works for you.

 

start /min /d "C:\Program Files (x86)\KCP\MPC-HC" mpc-hc.exe "E:\Documents Anime (Watching).et"


#4 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 01 May 2014 - 12:01 AM

Hi,

 

Your proposed solution tells MPC-HC to open the file, so I see "File not found" in MPC-HC's status bar. But I want the document to open with the program that it's affiliated with. I know how to achieve that if I rename the file to "Anime(Watching)" (i.e. I remove the spaces), but I'm not sure how to get Windows to open files that contain spaces in their name. Windows attempts to open "Anime" instead of "Anime (Watching)."

 

Below is what I have.

 

-

 

start /min /d "%userprofile%\Desktop" Anime (Watching).rtf
start /d "%userprofile%\Desktop\MPC-HC.1.7.4.x86" mpc-hc.exe

 

-

 

With this, Windows attempts to open "Anime" instead of "Anime (Watching)." Windows is not acknowledging the space in between "Anime" and "(Watching)." MPC-HC starts fine. I want the document to start minimized, and I want MPC-HC to start without being minimized.



#5 Kilroy

Kilroy

  • BC Advisor
  • 3,408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:06:59 PM

Posted 01 May 2014 - 12:28 PM

Whenever you have a space you can normally enclose it in quotes to get it to work.  If you are running from a batch file you can't run a non-executable.  Normally I try to avoid spaces to eliminate this as a possible issue.  Here is an example that creates and opens a file with a space in the name.

 

Echo %username% - %computername% >"C:\Windows\Temp\Computer Info.txt"
ipconfig >>"c:\windows\temp\computer info.txt"
notepad.exe "C:\Windows\Temp\Computer Info.txt"


#6 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 02 May 2014 - 01:09 AM

Well, I tried:

 

start /min /d "%userprofile%\Desktop\Anime (Watching).rtf"

 

and

 

start /min /d %userprofile%\Desktop "Anime (Watching).rtf"

 

Neither of them work.

 

This works though:

 

start /min /d "%userprofile%\Desktop" Anime(Watching).rtf

 

But I would prefer if I didn't have to avoid using spaces. It makes it more difficult to recognize files. I'm not sure how I'd rewrite the batch file using your example as a guide.


Edited by Dark Magician Girl, 02 May 2014 - 01:11 AM.


#7 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 02 May 2014 - 01:40 AM

I figured it out.

 

This works.

 

-

 

START /MIN %userprofile%\Desktop\"Anime (Watching).rtf"
START /d %userprofile%\Desktop\MPC-HC.1.7.4.x86 mpc-hc.exe

 

-

 

I had to remove the /d switch from the first line. The /d switch made Windows think "Anime (Watching).rtf" was part of the directory instead of a file to be launched. The quotation marks are necessary to make Windows acknowledge the spaces in the file name.

 

This line also works.

 

-

 

START /MIN "%userprofile%\Desktop\" "Anime (Watching).rtf"

 

-

 

I suppose I would have to do this if there were spaces in the directory.


Edited by Dark Magician Girl, 02 May 2014 - 01:44 AM.


#8 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 02 May 2014 - 01:51 AM

I still need help with the other things though. I would like to know if I could create a batch file that searches for running applications (not services and background processes) and issues a command to close them as well as prompts me to save work when applicable. Basically, I would like to create a batch file that I can execute at the end of a session and close all running programs. That way I don't have to manually exit out of each program.



#9 Kilroy

Kilroy

  • BC Advisor
  • 3,408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:06:59 PM

Posted 02 May 2014 - 11:00 AM

If you know the programs that might be running and stop them all would probably be easiest, at least from a batch file solution.

 

Taskkill is the command you will want to use.

 

TASKKILL /IM notepad.exe
TASKKILL /IM iexplorer.exe
TASKKILL /IM firefox.exe

 

Anything that isn't open will error, but not a big deal.

 

Another thing I've used in the past to deal with spaces is to build a variable that is what I want to do.

 

SET LOC="%userprofile%\Desktop\Anime Watching.rtf"
START /MIN %LOC%


#10 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 02 May 2014 - 07:38 PM

Thanks. That works. I tried it with notepad, and I was prompted to save changes. But is there not a way to create the batch file so that it looks for all running programs itself? Or, do I have to add all of the programs that I would use to the batch file?

 

Also, you mentioned earlier that launching a program without its splash would be a switch or setting used when launching the program. What do you mean by this? I know some programs have a setting that allows you to disable the splash screen, but not all of them do. That's why I'm wondering if there's a way I can start a program that doesn't have such a setting without the splash screen.



#11 Kilroy

Kilroy

  • BC Advisor
  • 3,408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:06:59 PM

Posted 05 May 2014 - 09:51 AM

The ability to suppress the splash screen will be unique to the program.  You may be able to launch the program like this.

 

START PROGRAMNAME.EXE /NOSPLASH

 

Or possibly a setting in the program's configuration.  It is also a possibility that there is no way to suppress the splash screen.

 

I'm sure there is a way to list running programs running using TASKLIST, but I'm not seeing a good way to shutdown only programs you've opened.  If you run this command replacing DOMAIN\USER with your account information you can see programs launched as you.

 

TASKLIST /FI "USERNAME eq DOMAIN\USER"

 

The problem is that this not just programs you launched, but also programs that start automatically, like those represented by system tray icons.



#12 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 05 May 2014 - 03:54 PM

Well, it's very hard to make out the names of the progams because the command prompt always immediately closes itself after a command is launched. But I was able to see explorer.exe as one of the processes. I suppose if I closed all running programs automatically, it would also be closed then. I guess it would be better to just name the programs I want to close in the batch file and update the names as I need to.


Edited by Dark Magician Girl, 05 May 2014 - 03:55 PM.


#13 Kilroy

Kilroy

  • BC Advisor
  • 3,408 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:06:59 PM

Posted 06 May 2014 - 08:33 AM

You need to run CMD first and then run the command or make a batch file with a pause.



#14 Dark Magician Girl

Dark Magician Girl
  • Topic Starter

  • Members
  • 230 posts
  • OFFLINE
  •  
  • Local time:06:59 PM

Posted 20 May 2014 - 07:24 PM

Sorry about the late response. 

 

Running the command prompt first worked. Explorer is indeed listed as well as the background processes for security programs. Certainly it's best to create a batch file with the names of the programs I want to close. Now that I think about it, there may be times when I want to leave certain programs running in the background but close other programs anyway. 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users