?
Solved

Shutting down the pc from an executable bat file

Posted on 2008-10-31
7
Medium Priority
?
804 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

762 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