Run before Windows

Hi,
I want to write a Visual C program that can run before Windows starts. That means, when you start your computer, before Windows starts, I want my program to start and change some configurations and delete some temp files (that will be locked by Windows)

Any ideas???

Regards
NBeeAsked:
Who is Participating?
 
nietodCommented:
Note that the flags like MOVEFIE_DELAY_UNTIL_REBOOT flag is only for MoveFilEx(), not MoveFile().   Also note that this flag only works on NT 4.0 and 2k.  Windows 95 and 98 force you to do this through a registery entry.
0
 
mnashadkaCommented:
I think that what you really want to do is to use the MoveFile command with the MOVEFILE_DELAY_UNTIL_REBOOT flag set:
MoveFile(old_file, new_file, MOVEFILE_DELAY_UNTIL_REBOOT);

This will allow the copy to be done when the computer restarts the next time, so the files don't get locked.  Hope this helps.
0
 
kuchnaheenCommented:
listening...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
mnashadkaCommented:
Sorry about that.
0
 
DanRollinsCommented:
I believe that commands in AUTOEXEC.BAT will execute before Windows starts.  

I recommend against doing anything in AUTOEXEC.BAT for any kind of release software, but for your own computer (or any easily maintainable on-site set of computers), it is a reasonable solution.

-- Dan
0
 
nietodCommented:
>> I believe that commands in
>> AUTOEXEC.BAT will execute
>> before Windows starts.
Before the "windows" part of windows. that is, before the GUI stuff.  its Autoexec.nt in NT and win 2k though.
0
 
makerpCommented:
surley MoveFile will not work before 'windows starts' ?, as this is a windows API call
0
 
nietodCommented:
It works before most of windows has started.  it can be used to copy over (update) or delete most of the windows files.  The function itself, the API call works when windows is fully running.  But it does nothing at that time (if you specifu the delay until reboot flag)  It just records what needs to be done, then the actions are taken when the machine is rebooted during the early stages of windows startup.
0
 
NBeeAuthor Commented:
nietod, you said on WIndows 9x, we must modify the registry entry. So what is it and how?
0
 
nietodCommented:
The details are documented with MoveFileEx() function in the VC help.

I was wrong however, it is not a registry entry, its an entry in the wininit.ini file.
0
 
NBeeAuthor Commented:
So, if i use the solution: edit wininit.ini, then can this be done on Windows 2000???

i want a single solution for many OS.

Thanks
0
 
NBeeAuthor Commented:
Heys, it doesn't work on Windows 2000 Profressional.
I have a Explorer.exe of my own. I want to replace Windows 2000 explorer.exe with the solution of MoveFileEx("C:\\Explorer.exe","C:\\Winnt\\Explorer.exe",MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING )

And it doesn't work any at all.
0
 
nietodCommented:
In win2k you can use MoveFileEx().  I know that it works.

What does MoveFileEx() return?
If it returns 0 (false) what does GetLastError() return?
0
 
NBeeAuthor Commented:
I didn't check what MoveFileEx() returned, but I checked in registry and found that key PendingFileRenameOperations had been created.
I restarted win2k but nothing has happened.
0
 
nietodCommented:
Check the return values.

It is possible that you don't have sufficient access rights.
0
 
NetminderCommented:
NBee,

The following questions are open, and have been open for some time. Further, your profile indicates you logged in as recently as Jan 29, 2002. Please resolve them within the next seven (7) days; following that period of time, I or one of the other Moderators will take action to close this question. Additionally, this list has been forwarded to Administration; please expect an email from them regarding your account's status.

http://www.experts-exchange.com/jsp/qShow.jsp?qid=11516478
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11529339
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11585158
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11697479
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11744478
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11766758
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11818478
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11905339
http://www.experts-exchange.com/jsp/qShow.jsp?qid=11938458
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20003831
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20038010
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20127372
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20135883
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20136023
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20142078
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20142830
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20143154
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20144259
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20144370
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20148973
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20150132
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20153238
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20160626
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20162000
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20163157
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20163178
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20163242
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20163142
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20163674
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20165141
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20174284
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20184042
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20242564
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20242585
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20252565
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20259368

Further, you should note that the guidelines for questions suggest that an "Easy" question is worth 50 points.

Thank you for your attention to the above questions.

Netminder
Community Support Moderator
Experts Exchange
0
 
NetminderCommented:
Admin notified of user neglect. Force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.