Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Urgent! Windows AUTOSTART program

Posted on 1999-08-01
12
Medium Priority
?
203 Views
Last Modified: 2012-05-04
How can I make a program that starts automatically when you start windows? It can't be in the "Startup" folder. (May be WIN.INI autoexec=...? What's the code to modify it?).
0
Comment
Question by:suguinha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 8

Expert Comment

by:shlomoy
ID: 1218758
try editing AUTOEXEC.BAT and CONFIG.SYS
these have remained since MS_DOS.

some other startup places are:
startup folder, WIN.INI, SYSTEM.INI - but the INIs depend on the application...
in any case the CONFIG.SYS comes up first, and AUTOEXEC.BAT comes up befor the GUI.
0
 

Author Comment

by:suguinha
ID: 1218759
It's for Windows, so I can't use CONFIG.SYS or AUTOEXEC.BAT... What I need is a code that changes WIN.INI (or SYSTEM.INI...) automatically to make the program start as you load windows (AFTER starting windows..)
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1218760
Windows 3.1?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:shlomoy
ID: 1218761
Sorry, I misunderstood.
0
 

Author Comment

by:suguinha
ID: 1218762
Windows'95...
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 1218763
If you don't wanna mess arround with the Register, then i suggest that you use [like stated up] the RUN parameter,

If you have Win3.x go to File Menu, then Run Submenu...
If you have Win 95 go to Start button, then Run menu...

Type SYSEDIT

then a set of windows will appear (the system files, like autoexec.bat, config.sys, Win.ini, etc) close the ones you're not going to moddify and select the one that says WIN.INI there should be some lines like:

    [windows]
    load=
    run=
    NullPort=None
    ...
    ...

In the line where says RUN= you type the name of the file you want windows to execute, if the file is not in the path then you should provide it too, like:

    [windows]
    load=
    run=C:\mydir\Myexefile.exe
    NullPort=None
    ...
    ...

:)
0
 

Author Comment

by:suguinha
ID: 1218764
It works, but what I need is a code that opens WIN.INI and changes it for me...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1218765
you should create a windows application for that since it would be easier to deal with INI files... you can still do it but a little bit harder.. read line by line (to save some memory, but slower) and then check the line, for whatever key you want to change... then just place your line there, and there you have it..

..-=ViKtOr=-..
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 1218766
0
 
LVL 6

Accepted Solution

by:
My name is Mud earned 100 total points
ID: 1218767
Since the Win.ini file is a text file you can doit very easy, but in this example is not treat it as a text file, insted you read it at once in a pointer var, and then seek the RUN line, once located you insert the command without wipeing out the others, if there were there...

Program WININI;
Const
  {This is where the WIN.INI file is located}
  WinIniName: String = 'C:\WINDOWS\WIN.INI';
  {This is the Command that you wanna add}
  ExeFileToAdd: String = ' C:\MYDIR\MYEXEFILE.EXE'; {Note the Space Before C:...}
Var
  WinIniBuff1,WinIniBuff2: Pointer;
  WinIniFile: File;
  WinIniSize: Word;
  RunLine: String;
  TestLine: String;

Function SeekRunLine(StringToAdd: String): Boolean;
Const
  Found: Boolean = False;
  JustOnces: Integer = 0;
Var
  I,Counter: Word;
  ACharVar: Char;
  WhereToInsert: Byte;
Begin
  Assign(WinIniFile,WinIniName);
  {$I-}
  Reset(WinIniFile,1);
  {$I+}
  If IoResult <> 0 Then
    Begin
      WriteLn('Damn there''s something wrong with ',WinIniName);
      Halt;
    End;
  WinIniSize:=FileSize(WinIniFile);
  If WinIniSize > 65535 Then
    Begin
      WriteLn('Damn there''s something wrong with ',WinIniName);
      Halt;
    End;
  GetMem(WinIniBuff1,WinIniSize);
  GetMem(WinIniBuff2,WinIniSize+Length(ExeFileToAdd));
  BlockRead(WinIniFile,WinIniBuff1^,WinIniSize);
  Close(WinIniFile);
  RunLine:='';
  TestLine:='';
  I:=0;
  For Counter:=0 to WinIniSize - 1 Do
    Begin
      RunLine:=RunLine+
        Char(PTR(Seg(WinIniBuff1^),Ofs(WinIniBuff1^)+Counter)^);
      TestLine:=TestLine+
        UpCase(Char(PTR(Seg(WinIniBuff1^),Ofs(WinIniBuff1^)+Counter)^));
      If (Pos('RUN',TestLine) <> 0) And (Pos(#13#10,TestLine) <> 0) Then
        Begin
          WhereToInsert:=Pos(#13#10,RunLine);
          Insert(StringToAdd,RunLine,WhereToInsert);
          Found:=True;
          JustOnces:=Length(ExeFileToAdd)
        End;
      If (Pos(#13#10,RunLine) <> 0) Then
        Begin
          Move(PTR(Seg(RunLine),Ofs(RunLine)+1)^,
               PTR(Seg(WinIniBuff2^),Ofs(WinIniBuff2^)+I)^,
               Length(RunLine));
          I:=Counter+JustOnces;
          RunLine:='';
          TestLine:=''
        End
    End;
  SeekRunLine:=Found
End;

Begin
  If SeekRunLine(ExeFileToAdd) Then
    Begin
      Assign(WinIniFile,WinIniName);
      ReWrite(WinIniFile,1);
      WinIniSize:=WinIniSize+Length(ExeFileToAdd);
      BlockWrite(WinIniFile,WinIniBuff2^,WinIniSize-1);
      Close(WinIniFile);
      WriteLn('Operation Completed...')
    End
  Else
    WriteLn('Opppssss...');
End.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1218768
>>{This is where the WIN.INI file is located}
>>       WinIniName: String = 'C:\WINDOWS\WIN.INI';
>>       {This is the Command that you wanna add}
>>       ExeFileToAdd: String = ' C:\MYDIR\MYEXEFILE.EXE'; {Note the Space
>>     Before C:...}

That is not true on non-English version of windows... That's why I said you should use windows and then use GetWindowsDirectory() to get the Windows directory on non-English version of Windows.. that way the Ini fiel handling would be a whole lot easier.. try using Delphi.. there you can use the object TIniFile and do this in no time with less memory... the code would not be as much either ;) you can create a console as well...

..-=ViKtOr=-..
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 1218769
Vic that's easy, just seek the MSDOS.SYS, there's a line where windows is hidden... :)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question