Re: Autolaunch a .bat file

From: Michael--J (MichaelJ_at_discussions.microsoft.com)
Date: 11/30/04


Date: Mon, 29 Nov 2004 23:37:04 -0800

Yes, i considered using the startup directory however there is one problem if
i do that: I have a shortcut link in that directory which runs another app.
The main purpose of my batch file is to update that particular app. So if i
put my batch file in the startup directory... what if the other app it's
supposed to update runs first? Then the batch file wont be able to update it.
So as a requirement, i need the batch file to run first.

I then tried writing a eVC++ program (called AutoPatch.exe) that looks like
this:

#include "stdafx.h"
#include <windows.h>
#include <winbase.h>
#include <tchar.h>

int WINAPI WinMain( HINSTANCE hInstance,
                                        HINSTANCE hPrevInstance,
                                        LPTSTR lpCmdLine,
                                        int nCmdShow)
{
         // TODO: Place code here.

        PROCESS_INFORMATION ProcInfo;

        // Let the system know we're done initializing.
        SignalStarted( 0x28 );

        // Launch cmd.exe here
        CreateProcess( L"cmd.exe", L"/C \\HardDisk\\patch.bat", NULL, NULL, FALSE,
CREATE_NEW_CONSOLE,
NULL, NULL, NULL, &ProcInfo );

        return 0;
}

This app is located in the \Windows folder and it's main purpose is to run
patch.bat using cmd.exe. Would having patch.bat in \HardDisk be a problem? I
remember reading that the hard disk may not be mounted when Init enumerates
its entries. Thanks.

"Yannick Chamming's [eMVP]" wrote:

> As long as the Hard Disk directory is available, you should be able to
> launch something from it. Now, I'm not sure that CE is able to launch .bat
> files. I think you'd better try launching cmd.exe with the right options.
>
> One thing you have to know : the HKLM\Init key startup mechanism
> automatically add to command line of the process launched the "Launch
> number" (in your case : 40). Maybe you should consider using the startup
> directory, which basically have the same goal, but at a more "applicative
> level".
>
> --
> ----------------------------------------------------------------
> Yannick Chamming's (eMVP)
> ADESET
> Windows Embedded Manager
> ychammings AT adeset DOT com>
> http://www.adeset.com
> Tél : +33 (0)4.72.18.57.77
> Fax : +33 (0)4.72.18.57.78
> ----------------------------------------------------------------
>
> "Michael--J" <MichaelJ@discussions.microsoft.com> wrote in message
> news:64326806-B444-4476-9D4B-B7CC8EC0C532@microsoft.com...
> > I tried changing the registry to:
> >
> > [HKEY_LOCAL_MACHINE\init]
> > "Launch40"="\HardDisk\patch.bat"
> >
> > But it still doesn't work. The contents of my batch file is this:
> > MOVE "\HardDisk\file.txt" "\HardDisk\test\file.txt"
> > CLS
> >
> > Does the file specified in the registry have to be part of the OS image?
> > Does it need to be an .exe or can it be a .bat? Can it be located in the
> > \HardDisk? Thanks.
> >
> > "Michael--J" wrote:
> >
> > > Hi,
> > >
> > > is there any way of autolaunching a batch file in CE 5.0? All i want to
> do
> > > is basically rename, delete, and move some files upon startup. I have
> tried
> > > the following:
> > >
> > > [HKEY_LOCAL_MACHINE\init]
> > > "Launch40"="patch.bat"
> > >
> > > [HKEY_LOCAL_MACHINE\Loader]
> > > "SystemPath"=multi_sz:"\\HardDisk","\\Release\\"
> > >
> > > patch.bat is the batch file i want to execute and is located in
> \HardDisk. I
> > > tried this out but it didn't work because the associated files i wanted
> to
> > > change didn't change. Is there another approach to this? Thanks
>
>
>



Relevant Pages

  • Launching a JAVAW application
    ... I am using a batch file to launch a javaw app. ... windows registry. ...
    (comp.lang.java.programmer)
  • Re: Installing Two Operating Systems 4 Speed
    ... No doubt an XClent advice but how 2 create a batch file to launch only ... MS-Office on startup and refraining other? ... "only and only" load Windows and MS-Office? ...
    (microsoft.public.windowsxp.general)
  • Re: Installing over an existing application.
    ... Vince wrote: ... What I did was to create a batch file which: ... >>sure the app is shut down completely before proceding (you can launch ... >>that batch file with Shell and immediately shut the app down) or... ...
    (microsoft.public.vb.enterprise)
  • Re: Automated way to kill a process?
    ... Either re-code the app to do this or write a batch file to do this. ... taskkill /im outlook.exe ... > My goal is to kill a process upon the launch of a specific ...
    (microsoft.public.windowsxp.general)
  • Re: Launching batch file at startup @ HKLMInit registries
    ... create a small helper application that launch cmd.exe with your batch ... helper app instead of the batch file and make sure the helper app ... I have to run a batch file at the startup. ...
    (microsoft.public.windowsce.platbuilder)