Jump to content

Creating a batch file to run upon logging into a docked state


Recommended Posts

I need to configure windows xp sp2 to run a batch file automatically after logging in when in the docked state, and not in the undocked state.

This batch file would run the following apps in order so that all desktop apps needed in the workday open automatically.

Outlook (along with preferred order of outlook windows)

Onenote

Yahoo instant messenger

Webex homepage (for daily reviw of meetings) Strike homepage (for weekly review of workflows) Documentation drive Siebel parts ordering site?

Task manager, minimized to tray

x amount of other minimal progs

I would think I need to consider embedding timeouts between each app starting up so that they open in the order I prefer.

What I'm looking for is the syntax this batch file would take; I've not written many so I imagine this is quite simple.

Can someone provide me with some direction? The whole idea is to be able to dock my laptop at my desk, boot up, log in. I then go to get mail/coffee etc. Once I arrive back my apps are loaded and waiting on me.

I know this sounds corny, but, I'm all about gtd and this would allow me to dive deeper into work quicker in the mornings.

Certainly someone else has considered this. Any feedback would be phenominal.

Thanks!!!

Link to comment
Share on other sites


This script takes advantage of the fact that a different hardware profile is loaded when a laptop is docked.

Assuming profile #2 is loaded in the docked state..

@echo off
setlocal
for /f "Tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\IDConfigDB" /V CurrentConfig^|FIND "REG_DWORD"') do (set /a profile=%%b)

if %profile%==1 goto undocked
if %profile%==2 goto docked
goto EOF

:undocked
echo Computer isn't docked.
goto EOF

:docked
echo Computer is docked. Launching programs...

START SomeRandomProgram.exe

:: Insert a 10 second delay :
ping -n 10 127.0.0.1>NUL

:: Starts Task Manager minimized
START /MIN taskmgr.exe

:EOF
endlocal

• I suggest you head over to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB and confirm the value of CurrentConfig when the laptop is docked and make any changes to the script (if necessary).

• There is no direct Sleep or Delay function in batch, but we can use the ping command to create a delay. Note that it's off by one second, so PING -n 10 actually causes a delay of 9 seconds :P

• You can use the START command to launch applications. Type START /? in the Command Prompt to find out more ways to launch apps.

Link to comment
Share on other sites

This is exactly what I needed!! Thank you!

How would one include an instance of internet explorer with a particular page displayed (ie. my google calendar?)

Thanks so much for the quick response! I'm testing the batch file periodically during the day.

I will post my final custom batch file once I've completed it. Perhaps others can take advantage of this time saver.

Does anyone think there's a better way to go about this than a simple batch file? This will work perfectly for me, however, I'm wondering what others have done when they needed a solution like this?

Thanks for the read.

Link to comment
Share on other sites

iexplore.exe "www.google.com"

.. or whatever page you want to open.

Does anyone think there's a better way to go about this than a simple batch file?

As such, there isn't any location where windows stores directly if a computer is docked or not. I guess the other way you can check for docking is to see if a particular hardware is present. If it is, then you'll know that the computer is docked.

Link to comment
Share on other sites

Man, you're quick to respond.

You must have email noti's setup when one responds.

This is so sweet. It may not look like much, but, this allows me to hit the ground running every morning.

Thanks so much for your assistance. I hope others find value in this thread.

Link to comment
Share on other sites

Well, you can create a VBS file that does that. If you want to call it from the batch file, just type its name :)

Copy-Paste this into a notepad window and save as "Refresh.vbs" (Don't forget to include the quotes!)

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Google - Windows Internet Explorer"
WScript.Sleep 100
WshShell.SendKeys "{F5}"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...