Batch File to automatically abort shutdown - batch-file

My computer shuts down every night starting at 9:59 and continuing until 11:59. I do not know why. I'm wondering if a .bat file could be written to automatically abort the shutdowns, or at least require confirmation?

It seems some unwanted software installed in your system. Check in the startup directory, remove any unwanted exe or batch files.
Check the scheduled task in windows using below command in older windows
at
After windows 7
schtasks.exe
Delete the unwanted tasks. Scan your system using Windows Defender
Below is the command used to abort the shutdown.
shutdown -a

Related

start a batch file on startup as administrator on win 10

I want to disable auto-updating on Windows 10.
I found out that disabling the service "WINDOWS UPDATE" will do this.
It did for some time, but when ever i restart my system it enables itself again and again. So I created batch file that disables it.
#echo off
NET stop "Windows Update"
I put it in startup folder but it worked only if it is executed as administrator. I tried to set properties of the shortcut to "RUN AS ADMINISTRATOR" but it stopped executing on startup.
Then I read about Task scheduler and added this task there but still its not working there even it just shows "The Directory Name is Invalid. (0x8007010B)

Using Task Scheduler to run a batch file that contains the start /w command

I have a Windows XP virtual machine that I am using to run a legacy app. I am using a limited user account.
I have created a batch file that I'd like to:
Start the legacy app
Wait for the program in step 1 to close
Shut down the computer
So this is the code I am using (in this example, I am attempting to open notepad):
#ECHO OFF
start /w notepad
%windir%\system32\shutdown.exe -f -s -t 1
Because the legacy app needs to be run under an account with administrator privileges, I then manually created a scheduled task in Task Scheduler to run the batch file. The scheduled task is set to run using an account named Admin that has administrator privileges.
I am having a bit of an issue. When the scheduled task runs, nothing appears on the screen. However, I did notice that both cmd.exe and notepad.exe appear in Task Manager as processes running as the user Admin.
What am I doing wrong? How can I accomplish what I'd like to do? Thanks!
Sorry all, it was an issue with me not having Task Scheduler set up properly. I found this post which suggests to use the AT command to run the task interactively. This allows the Cmd window to be displayed when a batch file is run as a Scheduled Task.

Running batch files on Windows 7 that were created on XP

I am having trouble running batch files on Windows 7 that I created, and which run properly as Scheduled Tasks, on XP. When I run these batch files as Scheduled Tasks on Windows 7, the command window just closes quickly. The batch files actually consist of a wrapper that initiates another batch file that contains branching and call Python scripts - so it's a little complicated.
I'm comparing differences between my Windows 7 and XP machines. When I run these batch files on XP, the top bar in the command window says C:\WINDOWS\SYSTEM32\SVCHOST.EXE. I set up a simple batch file (that doesn't contain a wrapper, branching or Python scripts) on the Windows 7 computer and at the top it says taskeng.exe, please see capture below.
Does anyone have a suggestion on what I need to do to get the batch files running on Windows 7 as scheduled tasks? Maybe there's something missing from my Environment Variables? I have checked the paths and everything in my more complicated batch files that I transferred to Windows 7 - I should say I can get the batch files running when I actually navigate to folder containing batch files I created. I really need them to run as Scheduled Tasks. I'm not particularly savvy with batch files, but these were running really well for 1+ year on my XP computer. Thank you! Patty
On Windows 7 when creating a a Scheduled Task you can choose 'Start In' you can then change the location in which it is run (and the directory to file you are refering to within your batch file.) This is worth trying before checking other things.
Second I would check what permissions it is being run with on Task Scheduler, run it as administrator to rule this out.
I would also see what happens when you just double click on the batch file as a logged in user and go forward from that.

Run file before windows

I need to run a *.bat or *.exe file, but before windows start.
There are some programs to manage partitions that do this, for example "Acronis Disk Director Suite" allows you to create a new partition within Windows and then it asks you to restart the PC, when you do this you will see a script running and modifying your disk and then Windows starts and you have your new partition right there.
What I want is just to be able to run a *.bat or *.exe file the same way.
as far as I am aware you can't run a windows file (.bat is a windows thing) without running some form of windows.
running an exe file is possible, but you would have to write it to interact with the hardware without any drivers.
if you just want it to run at startup of windows, google "windows reg startup" (no quotes).
or put the file in
"C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

Installshield - how to get the error thrown by the batch file to be displayed by the installer as a popup

I am currently working on creating installer. I have a batch file which checks the tasklist to see if the task is running. If the task is running - I want to pause the installer and give the user the option to retry or close. User will either manually shut down the task and hit retry or close the installer.
I am not sure how to link the batch files error response with the installshield.
Is it possible to do this activity using the batch file alone and not involve the installscript?
It's not possible. The .BAT file runs out of process and has no way of communicating back to InstallShield.
With InstallScript you can query WMI (Win32_Process) and drive the UI in a much more robust manner.

Resources