Solved

Shutting down the pc from an executable bat file

Posted on 2008-10-31
7
791 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Several part series to implement Internet Explorer 11 Enterprise Mode
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now