Disconnect automatically a vpn connection after 5 hours - windows

Is there a way to create a batch file or run some command like shutdown -s -t , where I can include time after which a vpn connection will be disconnected for example after 4 or 5 hours.
My gratitude to everyone.

I'd say you start this script up at a similar time that you start the VPN software up:
TIMEOUT /T 18000 /NOBREAK
TaskKill /f /IM VPNName.exe
This will wait for 5 hours, specified by the 18000 ( the seconds it should wait ) and will then forcefully close your VPN executable. Of course, you must replace VPNName with the executable's name. Also, you should try to change the /t value to test it as 5 hours is a long time to wait to test something.
By the way, this is a batch file.

thank you for your help. I have found something that may prove more useful in the future, though. It's called Perfect Automation, and I can record any action and set it to run at some specific time.
My thanks extended to the creator of this software as well as to you.

Related

Restart .bat file every 12 hours

i have a batch file on my server desktop called start.exe. I'd like to kill start.exe every 12 hours, than wait 2 seconds, and than restart start.exe. This should of course also work when no user is logged in on the server. So the workflow should be like:
Starting Windows Server
Starting start.exe
Restart every 12 hours
How can i achive this? With a script? With a task?
Run shutdown.exe in a scheduled task set to run every 12 hours. At a command prompt, type shutdown /? to see the options.

Run a batch file 5 minutes after startup in Windows Xp

I want to execute a .bat file 5 minutes after windows starts up. Unfortunately, windows task scheduler doesn't offer anything of the sort, only execute something right on start up. However, I need something to be 5 minutes after startup.
.bat file doesn't do much, just calls one separate .cmd file and passes a parameter. I've tried:
timeout /t 300 /nobreak
"C:\Documents and Settings\Administrator\Desktop\sikuli\runIDE.cmd" -r "C:\Documents and Settings\Administrator\Desktop\sikuli\SikuliXmlTestRunner.sikuli"
However, the runIDE.cmd gets called right away, regardless of the timeout.
You can give wait(300) command at the beginning in your sikuli script to achieve this.
XP doesn't have timeout command, use ping -n 300 localhost>nul or ping -n 1 -w 300000 localhost>nul.

Start cmd-scripts sequentually at system startup

I have Windows 2012 system with some servers. Every server starts with batch script, and some servers depends on another.
I need to start these scripts sequentially.
I have 4 cmd files: startMasterServer.cmd, startSlaveServer1.cmd, startSlaveServer2, startAnotherUtility.cmd.
Slave servers can start only after master server. But when I execute startMasterServer.cmd, it need 1-2 minutes to start. Another utility don't need anything for it, it can be started at any time.
How to manage autostart of servers in Window 2012? Maybe start scripts with timeouts or something???
And how to start my batch script when OS starts? No any user logged in at this time.
Maby you can use timeout 5 this for example will wait 5 seconds before continue the script.
So in your case you might want to use the following:
startMasterServer.cmd
timeout 120
startSlaveServer1.cmd
timeout 120
startSlaveServer2.cmd
timout 120
startAnotherUtility.cmd
Make another script that start the others scripts, placing timeouts between them.
Something like this:
#echo off
script1.cmd
timeout 120
script2.cmd
timeout 120
....
Then start only this script, and let it do the rest of the work.

Setup timeout for commands in Windows .bat file

I wrote a windows .bat script. To run a list of commands and then shut down the computer.
such as:
c:\someapplication.exe
c:\someapplication2.exe
Shutdown -s -t 0
Sometimes, "c:\someapplication.exe" freezes and do not respond. How can I setup timeout for my command "c:\someapplication.exe", so that after a certain amount of time, I want windows to force close the application and continue the rest of the commands?
You could use a combination of ping and taskkill to do this.
start c:\someapplication.exe
ping 127.0.0.1 -n seconds
taskkill /im someapplication.exe /f
start c:\someapplication2.exe
ping 127.0.0.1 -n seconds
taskkill /im someapplication2.exe /f
Shutdown -s -t 0 /f
Just replace seconds in the ping command with the number of seconds you want to wait before attempting to close the process (enough time so if it's still running it must have crashed). Then the rest of the app can continue until it is forced to shutdown.
if you may afford that all someapplications run in parallel try this
start someapplication
start someapplication2
wait n secons
shutdown
choose your value of n so that it does not proceed with shutdown while someapplications still run legit
or alternatively
start someapplication
wait n seconds
start someapplication2
wait m seconds
shutdown
for wait there are many solutions around, google some bat wait timeout
You can run your exe program and the shutdown command at once and put the timeout in shutdown options [-t].
To run multiple command at once, use "start" command ("start [yourProgram.exe]").
To do force shutdown use [-f] option.
good luck

User session timeout force logoff

I have been doing a little research on how to make a script using vbs or batch to set a session time limit for users logging onto a specific set of computers linked through Group Policy.
I am not familiar with log off or timed scripts, I can make the simplest batch script to log the current user off a machine. The problem I get to is not being able to set a timed session, or running the log-off script due to the time limit.
I researched setting it through group policy, then came up with the idea of linking a script to a group policy in the start up for users on the certain set of computers.
I found a vbs by googling key phrases but I am not sure exactly how to implement it with the log off script or how to make it begin its count down
echo.
echo Waiting For thirty minutes...
TIMEOUT /T 1800 /NOBREAKS
echo.
echo (logoff)
echo.
pause >nul
The log off script that I was planning on using goes along the lines of:
shutdown -l -f -t 30 -c "Your 30 minute session is over."
But I cant get the comment to display and the 30 second time doesn’t take affect.
Any help would be greatly appreciated. Thank you for reading.
How about somthing like this?
Set oSystems = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each oSystem in oSystems
oSystem.Win32ShutdownTracker 3600,"Logging off...",0,4
Next
I know this question is old but here you go anyway:
have a .vbs file called invis.vbs and place it in the Startup directory of the user you want to be limited.
It should contain the following (replace #username# with the Username):
wscript.exe “C:\Users\#username#\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Start-up\invis.vbs” “C:\SessionLimit.bat”
Now save the below as a batch file called SessionLimit.bat in the C:\ Directory.
It should contain the following:
#echo off
timeout 1800 /nobreak
shutdown /l ;;Replace this comment with /f if you want the log off to be forced without the Do you want to save your work interruption window.

Resources