creating a batch file to install

Jon123

Registered User.
Local time
Today, 14:42
Joined
Aug 29, 2003
Messages
668
Ok so I'm getting down to the nitty gritty here. I have my database ready
to go I have created a batch file that creates the dir and unzip's and modifies the trust center it works pretty well but I having 1 maybe 2 issues.

So I email the zip.exe file and a user copies this to their desktop
so now on the users desktop there is a folder that has all the files needed
to upload the program. So in my instructions I teel them to run the setup.bat file and this does everything for the user. When is finishes I want to delete both the folder that ran the bat file and the zip.exe file as well. I cant seem to figure out how to delete to folder that is open. Now if I move my bat file out of that folder it works. As for the zip.exe file how do I get the user's name for the path vr All User?

rmdir /s /q C:\"Documents and Settings"\"All Users"\"Desktop"\Fingersetup

thanks for the support
 
I understand your question so so.
Seems to me that this is a batch file problem. Wrong forum.

So you can't remove the stone you're standing on so if you move the bat file to a different location it should work.
As for the zip.exe file how do I get the user's name for the path vr All User?
I am not so familiar with the "vr" abbreviation.

So the users name can be extracted from the computer by executing the environ("username") command.

HTH:D
 
When the application is first launched you could get it to check for the existance of the batch file in the known folder. If exists then kill it along with the other files and folders that are now redundant.

David
 
you know that might be a better way to deal with it. I think I can launch it from the Batch file and then do the delete install files. Yes this should work. Thanks for the idea thank you

jon
 
Ok so how do I delete the folder on the desktop.
I have the code to test for it. I can delete all the files in the folder
but I cant delete the folder ???

Code:
    If Dir("c:\Documents and Settings\All Users\Desktop\Fingersetup\") = "" Then  ' Path present
    Kill "c:\Documents and Settings\All Users\Desktop\Fingersetup\*.*"
    Kill "c:\Documents and Settings\All Users\Desktop\Fingersetup"
[\code]
 
You don't kill a folder you remove it.

RMDIR take a look at the file scripting object. Kill removes files.

David
 
Got it - It works great now. It took a bit but now I have a simple winzip.exe program that will creat the folders needed, update the reg. security, copy the files over, create the short cuts on the users desktop and then launch the app. Once the app launches it removes the setup folders and files. It took me abit but works great. Again Thank you to everyone who has helped me get everything working.

jon
 
For the benefit of all the users who have contributed to this post can you post the solution for us all to see.

Regards
David
 
sure this was the code used to remove the setup files and folder
Code:
On Error GoTo Err_cmdOk_Click
    
    Dim fso
    Dim fol As String
    fol = "c:\Documents and Settings\All Users\Desktop\Fingersetup"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(fol) Then
    fso.DeleteFolder fol
   Else
    End If

one word of warning this will remove the folder and everything in it without warning its gone

jon
 
I was hoping you would supply the whole solution, not just the small snippet.
 
Sure I can do that. 1st a little history

So I had a small database that we use at our work. The database was created in access 2007 so the users are using Access runtime which creates the trust center issues (if you ever delt with it you know). We have about 65 users so not real big but I wanted a simple way to load the program and install it. I DID NOT include Access Run time in this install mainly because it was over 50 meg and I just did not want to send out a zip file that large. So I sent the runtime program out to them ahead of time and told them to install it 1st chance they get.

So 1st step was to creat a batch file that would update the registry file the user.

Code:
''''''''This code updates registry
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations]
"AllowNetworkLocations"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\whatever you want to call it]
"Path"="c:\\Finger Print\\" 
"AllowSubfolders"=dword:00000001
"Description"="Program description here"
"Date"="05.01.2009 12:00"
[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security]
"Level"=dword:00000001
"VBAWarnings"=dword:00000001

The nice thing about this code is it will update the users windows registry even if they do not have admin access to their box.

Next was the batch file which took me alot longer than it should of but it does work now.

batch file
Code:
@echo off
if  exist c:\"your folder" goto 2   ' " needed space in folder name

:1
echo Creating Directory Your folder
mkdir c:\"Your folder" 
mkdir C:\"Your folder"\subfolder1
mkdir C:\"your folder"\subfolder2
:2
echo Copying Current Version of the Program name here
copy C:\"Documents and Settings"\"All Users"\"Desktop"\setup\"program name.accde" c:\"Your folder"
copy C:\"Documents and Settings"\"All Users"\"Desktop"\setup\wetcleans.lnk "C:\Documents and Settings\All Users\Desktop"
copy C:\"Documents and Settings"\"All Users"\"Desktop"\setup\"Finger Print.lnk" "C:\Documents and Settings\All Users\Desktop"
echo File copy is complete
echo Your Registry file must be updated 
Call C:\"Documents and Settings"\"All Users"\"Desktop"\setup\registry.reg
Start C:\"your folder"\"program name.accde"
exit

pretty simple it creates the folders where the program goes
then it copies the files, then it copies the .ink files to the desk top these are just short cuts to the program. I could not figure out how to creat them in the batch file but found I could create them 1st then copy them into the zip file and during the install just copy them out. Then I Call the registry.reg file that will update the registry. Next I start the database in case you did not know if you call a program in a bath file the batch file waits before moving on if you Start a program then the bacth file will continue and in my case end and exit once access is started which is important because you can not delete a file that is running.

Now that the program was installed on the users laptop I wanted to delete the install folder and the zip program used to do the install. The dbase opens and my splash screen opens and then it goes to a user logon form. The user name and password. Once they enter their name and password and click cmdOK this code runs
Code:
    Dim fso
    Dim fol As String
    fol = "c:\Documents and Settings\All Users\Desktop\setup"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(fol) Then
    fso.DeleteFolder fol
   Else
    End If
   
   If Dir("c:\Documents and Settings\" & Me.CurrentUser & "\Desktop\Setup.exe") = "" Then GoTo 10 ' file not there
   Kill "c:\Documents and Settings\" & Me.CurrentUser & "\Desktop\Setup.exe"

the 1st part here deletes the folder on the all user desktop called setup
which again it deletes everything in that folder with out warning. The part I had more trouble with was getting rid of the Zip file that started it all because it was copied from an email to the users desktop not the All users desktop so I needed to find out who was logged to know what the correct path was. Currentuser is a field name on the loging screen which users dont see. I have the control source set to '=GetWinUserName()'
and I added this code to a module.
Code:
Function GetWinUserName()
GetWinUserName = VBA.Environ("UserName")
End Function

and I believe that is it. So now when sendout a new program I just need to make sure the names of everything are the same and this works well.

Again thankyou to all the user and users post that halp me put this together.
and yes I know its a Batch file but I figured the users on this site have always been very helpful to me over the years and they would be able to help me and what do you know I was right they were and they did

Thanks to ALL

jon
 
Last edited:

Users who are viewing this thread

Back
Top Bottom