Hi,
1. What is the best way to start a Driver (Net Start %DriverName%) after I installed it?
You can either use "net start %DriverName" or you can use "sc start %DriverName". Either way works just fine.
2. What is the best way to run a command line (Probably as Custom Action?)
3. Is there a way that running a command line will keep the black console window hidden and will not be displayed to users?
To achieve this, you can use this script:
Code: Select all
'Usage:
'- Save this script as ExecuteBat.vbs
'- from the Custom Actions page, add a new Attatched Custom Action
'- select ExecuteBat.vbs from the Browse dialog
'- make sure the Source Type is set to "Visual basic script (*.vbs)
'- set the Function Name field to ExecuteBat
'- the Action Data field must be in this format:
' <full path to .bat>|<.bat file's working directory>|< 0 for running hidden, 1 for running visible>
' Example:
' [MYPATH]mybat.bat | [WindowsVolume]Windows | 0
'- note that no quotation marks should be used
Function ExecuteBat()
Dim WindowStyle_Visible, objShell, result, actData, batfilename,workingdir,thirdparam, x
'extracting the parameters
result= Session.Property("CustomActionData")
'splitting the parameters
actData = Split(result,"|")
batfilename = actData(0) 'first parameter is the full path to the bat
workingdir = actData(1) 'second parameter is the working directory
WindowStyle_Visible = actData(2) 'third parameter, is the cmd window visible?
'strip the additional spaces at the beginning and the end of the string
workingdir = LTrim(workingdir)
workingdir = RTrim(workingdir)
'creating the shell object
set objShell = CreateObject("WScript.Shell")
'setting the current working directory
objShell.CurrentDirectory = workingdir
'adding the required quotes
batfilename = """"&batfilename&""""
'running the bat file synchronously to avoid unexpected behavior due
'to interference with the install process
'this behavior can be overridden by selecting Asynchronous execution from Advanced Installer
result = objShell.Run("cmd.exe /c "&batfilename&"" , WindowStyle_Visible,1)
End Function
4. Is it possible to run bat file as "File Attached to Installation" mode? (So the batch file will not exist in the Program folder)
I am afraid this is not possible. You can however add your bat as temporary file from the "Files and Folders" page, then on the custom action used to launch the ExecuteBat script, set the Action Data to something like:
Note that the second parameter need not necessarily be [APPDIR], it can be whatever working directory you like for your .bat file.
Regards,
Gabriel
FOLLOW US
Get the latest news in Application Packaging