Schedule a Task in Vista - System Restart - scheduled-tasks

I am trying to write a system restart Task for Windows Vista. I'm a web developer by trade so I'm a little out of my element here. I have got into my OS and discovered Task Scheduler.
So far I've been able to set up some various tasks to run small WPF programs by calling the *.exe files. What I really need to do is set up a system restart at a specific time. 1 a.m. for example.
Is there a way to write a simple shell script that will force restart Windows Vista as a scheduled task?
My concern is that Vista typically asks to shut down programs when you hit restart, so I would want to make sure that it really is automatic requiring zero user interaction.
Any help, or links to examples would be greatly appreciated.
System: Windows Vista 32bit
Cheers,
Ryan
Answer: Copy and Paste the code in the selected answer to a text file.
shutdown -r -f -t 01
Save the file as a *.bat file. You can then select it in the Actions Tab of the Task Scheduler. Works like a charm.

Execute
shutdown -r -f -t 01
will restart windows in 1 second.

Related

How to launch a script that execute a check disk (chkdsk) without manual confirmation in Powershell?

I have a supervision tool that can deploy scripts on customers end devices.
I'm trying to make two powershell scripts.
The first one is supposed to launch a "chkdsk disk_name: /f /r".
The second one is supposed to extract the result of the chkdsk after the reboot from the event viewer.
The second script is operational. My problem is with the first one.
I think that when I'm launching my job from my administration tool, the script is launched on the end device, but when you type "chkdsk disk_name: /f /r" on a command prompt, it asks if you want to do the chkdsk at the start of the machine because the disk is actually in use. I think that the letter "Y" that you have to type to confirm, is blocking the execution of the command (and my script by consequence).
I didn't find in the documentation of the command any method to launch it with a "default confirmation".
Do you have any idea of what I can do to automate this?
Sorry for my English, it's not my native language.
Thank you all!
I tried to launch the script (it's in admin mode when my administration tool launch it's job) but the result was that my job was running indefinitely and at the restart of the machine, the check disk is not performed.

Disconnecting OpenFiles

I've been researching and learning about windows batch files, PowerShell and cmd these past few days.
We're having issues with Open Files, so we manually go to the server and do it with a press of a button. But since there might be a possible way to automate it and do the script every 5 minutes.
Someone helped me already telling me that I should make a script of
openfiles /disconnect /a* /op "E:\SERVERNAME\"
& so I did and put it on the Windows Task Scheduler Action Tab - Start a Program and put the file path of the batch file that I made.
But It seems that it's not working and we're still having the same issue.
I hope I made it clear.

Automating Month End Process

Whether month end process can be automated in progress bases applications like nessie? I already searched for it and I think maybe it can done by scheduling it through background jobs.
Scheduling jobs is a function of the OS or of 3rd party applications that specialize in such things (generally used in large enterprises with IT groups that obsess over that kind of stuff).
If you are using UNIX then you want to look into "cron".
If you are using Windows then "scheduled tasks".
In any event you will need to create a "wrapper" script that properly sets the background job environment and launches a Progress session. If you are using Windows you should be aware that a batch process is "headless" and that unless your batch process is doing something very strange it will not be using GUI components -- so you should probably run _progres.exe rather than prowin32.exe.
A generic (UNIX) example:
#!/bin/sh
#
DLC=/usr/dlc
PATH=$DLC/bin:$PATH
export DLC PATH
_progres -b -db /path/dbname -p batchjob.p > logfile 2>&1 &
(That is "_progres" with just 1 "s" -- this is from the days when file names were restricted to 8 characters on some operating systems.)
Windows is very similar:
# echo off
set DLC=c:\progress
set PATH=%DLC%\bin;%PATH%
_progres.exe -b -db \path\dbname -p batchjob.p > logfile 2>&1
But there are a lot of "gotchyas" with Windows. If, for instance, you run a job using a login-id that might actually login then you will have the problem that on logout all the scheduled tasks will be "helpfully" killed by the OS. Aside from stopping your job when you probably don't want it to this may have other negative side effects like crashing the db. To get around that problem on Windows you either create a "service account" that never logs in or use 3rd party scheduler that runs jobs "as a service".

Starting XAMPP with batch only if it isn't already running

I am writing a batch for a new deployment of my company's software.. Here is what I have so far...
wscript.exe "invisible.vbs" "apache_start.bat" /wait
wscript.exe "invisible.vbs" "mysql_start.bat" /wait
"C:\Program Files\Internet Explorer\iexplore.exe" http://localhost
So as you can see, this script should start apache, then start mysql and then open the default page with IE.
The problem is if the user runs this script twice, it runs apache and mysql twice and loads two seperate instances. The solution I need is a way to check to see if the processes are already running and, if not, run the two wscript commands. I am absolutely horrible with shell, so please try to give specific responses! I am a software engineer, not a sysadmin. Thanks for the help!
As a software engineer I think you have a leg up on scripting over some sysadmins...
Using PowerShell would make this easy. Use the following template to execute the services - you'll need to use it twice, and follow up with launching IE as above.
If ((Get-Process mysqlprocessname.exe)) {Write-Host Skipping MySQL}
Else { Start-Process ...}
This is going to take a few minutes for you to research the best way of starting a process with PowerShell. Also, you might want to pipe Start-Process to Out-Null so the script waits to start IE and Apache.
Others may want to chime in with a simpler way from a batch file.
For XAMPP, there is a pv.exe file in the apache/bin folder that XAMPP uses to see if a service is running. Look at WorldDrknss' answer in this thread for some great info: http://www.apachefriends.org/f/viewtopic.php?p=80047
The code to solve your problem is to modify your mysql_start.bat file to this:
#echo off
apache\bin\pv mysqld.exe %1 >nul
if ERRORLEVEL 1 goto Process_NotFound
echo MySQL is running
goto END
:Process_NotFound
echo Process %1 is not running
mysql\bin\mysqld.exe --defaults-file=mysql\bin\my.ini --standalone --console
goto finish
:finish
That will check if mysqld.exe is running. If it is, it just echos that out. If not, it starts the service.

How to invoke an opened Exceed window to run a Perl script using a Schedule Task

TASK TO BE ACCOMPLISHED:
To schedule a perl script which is executed on a specific time / day in a week
THINGS I HAVE DONE:
In a schedule Tasks, I have created a new Task by which the Task will call a batch file with below contents
cd "DRIVE\FOLDER\Hummingbird\Connectivity\14.00\Exceed\"
ABCD.xs
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
THINGS NOT WORKING FOR ME / CAUSING THE ISSUE:
Wen I run the scheduler, the prompt opens up the ABCD.xs exceed file window seperately file but the below commands are executed in the command pronpt itself
EXPECTED OUTPUT:
I want the commands
cd mDrive/bin
perl baseline.pl -publish -location XXX -email
to be executed in the exceed window
Any kind of solution wud be great
Thanks in advance.
Haresh
Sounds like you need to start getting into either SendKey stuff (Win32 packages) or else look into writing Exceed/Hummingbird scripts and just executing those.
Some other things to look into... does the remote server have a telnet or ssh server running? Or are there other methods of executing code on the remote server?
For example, my work's mainframe is accessed via a Hummingbird terminal emulator, but I can also telnet to the mainframe and execute commands as well as FTP batch job directly into the JES spool. So when I execute things on the mainframe by way of my PC (Perl scripts, etc.), I don't even fool with Hummingbird.
Good luck...