Solved

Shutting down the pc from an executable bat file

Posted on 2008-10-31
7
799 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
robocopy 33 115
PerfMon Report Time Out 6 42
Auto-launch VPN via Wifi 7 49
Windows 10 in-place ugprade stuck on 0% 6 32
This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
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…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
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…

856 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