Solved

Shutting down the pc from an executable bat file

Posted on 2008-10-31
7
802 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
Independent Software Vendors: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

749 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