Help Writing a Batch File

  Dumfy 18:10 26 Mar 2012

Hi All

Can anyone help me get a simple batch file to work please?

I'm trying to write a file that will be integrated with Windows Scheduler to auto reconnect my VPN when the PC comes out of sleep mode. For some reason, Windows always disconnects the VPN when entering sleep/hibernate.

Have done a lot of "Googling" on this and found the following . .

--Here is the suggested batch file script--

rasdial.exe yourvpnconnectioname username password

I've written this but cannot get it to work. The Command Window flashes up, but nothing happens. It seems straightfoward - but not for me!

If anyone knows a better way of getting the VPN to auto reconnect after coming out of sleep I would be grateful. It would also be beneficial if it auto reconnects at boot time to save having to log in separately.

Many Thanks

  Fruit Bat /\0/\ 18:40 26 Mar 2012

What version of windows?

  Dumfy 19:58 26 Mar 2012

Apologies - meant to write this in to the original post and forgot . . .

Running Win 7 64 bit


  Fruit Bat /\0/\ 21:32 26 Mar 2012

device manager - network adaptor - right click - select properties - Power management tab - untick allow the computer to switch off...

Also try disabling ipv6 here

  Dumfy 08:54 27 Mar 2012

Hi Fruit Bat /\0/\

Thanks for the info, however, I have only one tab available in device manager - network adapter and that is a General Tab under properties. No power managment tab at all. In fact, it's the same for everything in the Device Manager window. Selecting properties just gives me a General Tab.

If I can get to what your describing I think it should work. I assume unticking allow the computer to switch off . . . would prevent indows disabling the VPN?



  Fruit Bat /\0/\ 09:05 27 Mar 2012

You may have to access it as an administrator to get at the tabs you need

  bobbybowls 09:36 27 Mar 2012

click on the arrow next to network adaptors. then right click on the adaptor.

  Dumfy 09:45 28 Mar 2012

Thanks Guys. Don't know what I did yesterday - trying too hard after a long nightshift I think.

The Power Management Option Tab is there for the network adapters and "allow computer to switch off off" is now unticked.

However it still disconnects the VPN in Hibernate. Have also tried Sleep instead of hibernate - same.

Previously I installed OpenVPN and have tried to keep this active during sleep with no luck. More Googling and I edited the Config file and added a line keepalive 10 120 That didn't work either. I just added the line in the Config File to what was already there. Don't know if this is correct as I don't have a clue about writing these or batch files.

Anything else I could try?

  Fruit Bat /\0/\ 13:54 28 Mar 2012

Ok so the easy things didn't work :0(

so back to the batch file

try a comma

rasdial.exe, VPNName Username Password

  lotvic 15:26 28 Mar 2012
  robin_x 19:01 28 Mar 2012

When testing a .bat file, I find it helpful to use the sleep command as the last line.

You are then asked to Press a key when the code above it finishes before the cmd Window closes and flashes off.

So an example .bat file would be

rasdial.exe yourvpnconnectioname username password


Since I can never remember how to set Windows Permissions properly, I also find if I want to double click and Run it as Admin, I create a short cut to the .bat and make it Run As Admin in Properties.

When testing is finished, the .bat can be referenced by Scheduler and the Highest Privileges etc selected.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Huawei MateBook X Pro review: Hands-on

The art of 'British' pulp fiction

Best password managers for Mac

TV & streaming : comment regarder le Tournoi des Six Nations 2018 ?