Solved

Shutting down the pc from an executable bat file

Posted on 2008-10-31
7
803 Views
Last Modified: 2013-11-11
I am running a media player on thousands of machines from which I am able to set a shutdown time within the media itself (i.e. when a specific media runs it shuts the pc down by association with my shutdown exe). This does work but I am getting an error message on shutdown as stated. It shutsdown through this but I really want to get rid of the error message - any ideas?

Here is my simple bat file code:

@echo off

shutdown.exe -s -f -t 0

Which is converted into an executable using bat2exe converter.

The program works fine with nothing else running but has trouble with the media player I guess - though the error reported is on cmd.exe? I have tried using taskkill and tskill but neither are available in dos on this system. Is there any other way of remotely shutting down the programs? i.e another command I'm not aware of? Also - can I stop the cmd prompt window from appearing on my screen even if briefly?

Thanks for any help.
0
Comment
Question by:deathbybatfile
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22852348
Unlikely that you'll be able to hide the cmd window.  You can eliminate that first line though and just precede the shutdown command with a @ - accomplishes the same thing.

How are you launching this within the media?
0
 

Author Comment

by:deathbybatfile
ID: 22853232
Hey there - thanks for the response. Part of the media player is an application loader which allows me  to run any program that I download along with standard media files. All it does is executes the program so I've been havin a lot of fun writing bat files and then compiling them into executables to automate a number of tasks. This is the last one I need to wrap up and this damn error message is the only thing I need to get rid of. The media player that is running is the one that calls the program to run - could that be the issue? Or should I be able to get this to shutdown smoothly once started regardless of what's running?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22853423
What if you compile it to run in its own shell?

@cmd /c shutdown.exe -s -f -t 0
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:141ANG
ID: 22854122
You could also do it in a VBS
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "c:\windows\system32\cmd.exe /c shutdown.exe -s -f -t 0

Open in new window

0
 

Author Comment

by:deathbybatfile
ID: 22855211
That's great thanks - I'll try those when I'm back at work on Monday.
0
 

Accepted Solution

by:
deathbybatfile earned 0 total points
ID: 22866250
@cmd /c shutdown.exe -s -f -t 0 still gave the error and I'm not sure what I would need to download/use to write/compile something in VB Script?

Anyway I got rid of the error message!!!
Simple really - just included the tskill.exe in the compiled app and once that was there I just ran code as:

@echo off

tskill playlist
tskill player

shutdown.exe -s -f -t 0

This now gives no error message and shuts down cleanly!!!

0
 
LVL 1

Expert Comment

by:141ANG
ID: 22909652
sorry two things, first write the file in a txt format, then save it as a .vbs also I forgot the closing quotes on the end of the code.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question