Hi,
I'm using VFP 9.0 SP2 and InstallShield Express. During installation I need to copy a dll-file during to the c:\windows\system32 directory and register it with regsvr32, but couldn't find an option in Installhsield for accomplishing that. In Installshield there is an option to self-register, but it didn't help with this dll-file.
Then I tried to achieve this process after the installation upon running the application, by using foxpro commands.
I was able to register a dll file from within foxpro by using ShellExecute with Administration rights in this way:
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
ShellExecute(0,"runas","regsvr32.exe" ,"c:\windows\system32\myDLLfile.dll /s","",1)
I works well.
But I didn't find a way to copy a file to windows\system32 using ShellExecute.
Therefore, I tried a totally different apporoach:
I created a batch file with a script inside it, which first elevates the batch-file to have administrator rights and subsequently runs a copy command, then a regsvr32 command:
<!-- : --- Self-Elevating Batch Script ---------------------------
@whoami /groups | find "S-1-16-12288" > nul && goto :admin
set "ELEVATE_CMDLINE=cd /d "%~dp0" & call "%~f0" %*"
cscript //nologo "%~f0?.wsf" //job:Elevate & exit /b
-->
<job id="Elevate"><script language="VBScript">
Set objShell = CreateObject("Shell.Application")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objWshProcessEnv = objWshShell.Environment("PROCESS")
strCommandLine = Trim(objWshProcessEnv("ELEVATE_CMDLINE"))
objShell.ShellExecute "cmd", "/c " & strCommandLine, "", "runas"
</script></job>
:admin -----------------------------------------------------------
xcopy C:\myapp\myDLLfile.dll c:\windows\system32 /D/S/Y/R/E/F/G/H
regsvr32 C:\windows\system32\myDLLfile.dll
When running the batch-file by dobble clicking it in windows explorer, everything works fine.
But when I run the batch file from within VFP by the command "RUN C:\myapp\mybatchfile.bat", the batch-file isn't able to copy the dll-file to windows\system32. Interestingly, the registration part (regsvr32) works flawlessly, when first manually copying the dll-file in the windows\system32 directory. But the copying is simply not performed, there is no error message either.
Is there any way to solve this somewhat "simple problem" of copying a file to windows\system32 and registering it (administration rights needed)? Moving away from Installshield Express to another program like Inno Setup would be too difficult and time consuming for me at the moment.
Any help would be highly appreciated.
Thanks,
Manni
I'm using VFP 9.0 SP2 and InstallShield Express. During installation I need to copy a dll-file during to the c:\windows\system32 directory and register it with regsvr32, but couldn't find an option in Installhsield for accomplishing that. In Installshield there is an option to self-register, but it didn't help with this dll-file.
Then I tried to achieve this process after the installation upon running the application, by using foxpro commands.
I was able to register a dll file from within foxpro by using ShellExecute with Administration rights in this way:
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
ShellExecute(0,"runas","regsvr32.exe" ,"c:\windows\system32\myDLLfile.dll /s","",1)
I works well.
But I didn't find a way to copy a file to windows\system32 using ShellExecute.
Therefore, I tried a totally different apporoach:
I created a batch file with a script inside it, which first elevates the batch-file to have administrator rights and subsequently runs a copy command, then a regsvr32 command:
<!-- : --- Self-Elevating Batch Script ---------------------------
@whoami /groups | find "S-1-16-12288" > nul && goto :admin
set "ELEVATE_CMDLINE=cd /d "%~dp0" & call "%~f0" %*"
cscript //nologo "%~f0?.wsf" //job:Elevate & exit /b
-->
<job id="Elevate"><script language="VBScript">
Set objShell = CreateObject("Shell.Application")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objWshProcessEnv = objWshShell.Environment("PROCESS")
strCommandLine = Trim(objWshProcessEnv("ELEVATE_CMDLINE"))
objShell.ShellExecute "cmd", "/c " & strCommandLine, "", "runas"
</script></job>
:admin -----------------------------------------------------------
xcopy C:\myapp\myDLLfile.dll c:\windows\system32 /D/S/Y/R/E/F/G/H
regsvr32 C:\windows\system32\myDLLfile.dll
When running the batch-file by dobble clicking it in windows explorer, everything works fine.
But when I run the batch file from within VFP by the command "RUN C:\myapp\mybatchfile.bat", the batch-file isn't able to copy the dll-file to windows\system32. Interestingly, the registration part (regsvr32) works flawlessly, when first manually copying the dll-file in the windows\system32 directory. But the copying is simply not performed, there is no error message either.
Is there any way to solve this somewhat "simple problem" of copying a file to windows\system32 and registering it (administration rights needed)? Moving away from Installshield Express to another program like Inno Setup would be too difficult and time consuming for me at the moment.
Any help would be highly appreciated.
Thanks,
Manni