Running sql and other commands?
I need to run some sql and dot net commands as part of an installation such as the following:
SQL commands:
Dot net commands:
What I need to know is if all this stuff would go into the CustomAction table or if there is another method for running these types of commands. Should they go in batch files that get deployed and run using custom actions or stored in the custom action itself if even possible? Why I ask is because my only tools are Orca and InstEdit. Thanks to the members here I know how to add VBscript custom actions but I'm not sure about the above commands.
SQL commands:
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = someUser')
CREATE LOGIN [someuser] WITH PASSWORD = 'somepassword'
GO
/*specify the database*/
USE [local]
GO
/*create new database role*/
CREATE ROLE db_executor
GO
/*grant execute to the role*/
GRANT EXECUTE TO db_executor
GO
/*Create User*/
CREATE USER [LocalSQLUser] FOR LOGIN [LocalSQLUser] WITH DEFAULT_SCHEMA=[dbo]
GRANT CONNECT TO [LocalSQLUser]
GO
Dot net commands:
ren "C:\Program Files\Application\Mobile.exe.config" "web.config"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "connectionStrings" "C:\Program Files\application"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "appSettings" "C:\Program Files\application"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "system.net/mailSettings/smtp" "C:\Program Files\application"
ren "C:\Program Files\application\web.config" "Mobile.exe.config"
ren "C:\Program Files\application\DBSync.exe.config" "web.config"
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "applicationSettings/DBSync.Properties.Settings" "C:\Program Files\application"
ren "C:\Program Files\application\web.config" "DBSync.exe.config"
What I need to know is if all this stuff would go into the CustomAction table or if there is another method for running these types of commands. Should they go in batch files that get deployed and run using custom actions or stored in the custom action itself if even possible? Why I ask is because my only tools are Orca and InstEdit. Thanks to the members here I know how to add VBscript custom actions but I'm not sure about the above commands.
0 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
anonymous_9363
14 years ago
Given the number of commands here and the relative complexity, I'd be tempted to build a VBScript. Apart from anything else, you'll get better error-handling (provided you add that, of course!) and control. For example, you could build a function for the call to ASPNet_RegIIS and pass in the different parameters - much more efficient. Additionally, you can test the whole thing externally before you add it to the package. Lastly, you'd only need add ONE Custom Action.
Posted by:
joedown
14 years ago
I can go with that. If I have a single VBScript to do all the commands I'm guessing that it would be too long to use a type 38 custom action. So will I need to utilize the Binary table for this script?
ORIGINAL: VBScab
Given the number of commands here and the relative complexity, I'd be tempted to build a VBScript. Apart from anything else, you'll get better error-handling (provided you add that, of course!) and control. For example, you could build a function for the call to ASPNet_RegIIS and pass in the different parameters - much more efficient. Additionally, you can test the whole thing externally before you add it to the package. Lastly, you'd only need add ONE Custom Action.
Posted by:
anonymous_9363
14 years ago
That would safest, yes. However, by externalising the script, you lose a ceratin amount of flexibility, in that you no longer have access to MSI properties, unless you pass them on the command line or write them out to the registry before calling your script, which then reads them. I have many MSIs with embedded scripts much larger than MS's arbitary limit and I honestly can't see MS enforcing the limit anytime soon.
Posted by:
joedown
14 years ago
I've been able to get my whole script working except for the section where I'm calling the aspnet_regiis command. For some reason it is not working through the script but does work externally of the msi. So I'm wondering if there is a specific way I need to call this executable in a vbscript within an MSI.
Code snippet below
Code snippet below
StrMessage = "Current install variable: Path ->" & StrInstallFolder & "OSL.RMS.Mobile.exe.config"
WriteLog LogFilePath, StrMessage
'Rename RMS Mobile config file: wait for it to complete before moving onto next step
StrCurrentFile = StrInstallFolder & "OSL.RMS.Mobile.exe.config"
StrNewFile = StrInstallFolder & "web.config"
renameFile StrCurrentFile, StrNewFile
StrMessage = "Successfully renamed ""OSL.RMS.Mobile.exe.config"" to ""web.config"". Status:"
'StdOut.WriteLine(StrMessage)
WriteLog LogFilePath, StrMessage
StrMessage = "Current install variable: EncryptionCmd ->" & StrDotNetBinFolder &"aspnet_regiis -pef ""connectionStrings"" """&StrInstallFolder&""""
WriteLog LogFilePath, StrMessage
'Encrypt connection strings: wait for it to complete before moving onto next step
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("cmd /c"&StrDotNetBinFolder &"aspnet_regiis -pef ""connectionStrings"" """&StrInstallFolder&"""")
Sleep(1)
StrMessage = "Successfully encrypted connection strings. Status:"&oExec.Status
'StdOut.WriteLine(StrMessage)
WriteLog LogFilePath, StrMessage
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.