WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DLLs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Update Locked WinBatch DLLs

Keywords: DLLs update DLLs  file locks locked files wininit.ini	 automatic update

Question:

This is probably something you've been asked for before, but:
When copying files to local disk, what is the easiest way to update DLL files that is locked by the system ??

Answer:

This is a major problem.

In Windows NT it is fairly easy. See IntControl(30, ...)

In Windows 95 you make a file called WININIT.INI. It tells the system what to do when you reboot the machine. You copy the file to the drive you need it on with a different name and make a WININIT.INI file in the Windows directory "DirWindows(0)" that looks like:
P.S. You must use the SHORT version of the filename (see FileNameShort).

[rename]
;  newname=oldname
c:\xxx\myfile.dll=c:\xxx\myfile.tmp
c:\xxx\somedll.dll=c:\temp\tempname.dll

; to delete a file...
NUL=C:\yyy\trash.exe
In Win16 you make a BAT file and execute it with the RunExit function.

How to Update WB compiled EXEs

It is *really* hard for a WinBatch script to update itself. However you can solve the problem by the following trick (NB: pseudo code here):
   ; User launches compiled WBT file
   Exe file checks server to see if update is required.
   if update not required
        run normal code
   else
        run update program on server
        EXIT
   endif

;*******************************************
;And now for the update program
   TimeDelay(5)   ; wait for original program to exit
   FileCopy("new.exe","old.exe",0)
   Run the program again
   exit

Automatic Updating of EXE's: Another Option

If you don't mind restarting Windows 95, there may be an elegant enough solution:

The self-updating program could start like this:

If 

   RunOnce = RegOpenKey ( @RegMachine , `SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce` )
   RegSetValue ( RunOnce , `[Command]` , `command.com /c copy \\SERVER\SHARE\WBNEWVER\mywbpgm.exe C:\myplace` )
   RegCloseKey ( RunOnce )
   IntControl ( 67 , 0 , 0 , 0 , 0 ) 

End If
When a new version is detected, the program itself places the command line in the registry and reboots. Anything placed in the runonce section is executed once and then automatically removed.

What I cannot tell is if the copy will take place before the program is executed. It depends on its location in the chain of events. This you will have to check...


Article ID:   W13192
Filename:   Update WinBatch DLLs and EXEs.txt
File Created: 1999:04:15:16:52:22
Last Updated: 1999:04:15:16:52:22