I build an installer with Basic MSI Project in InstallShield 2010.
My setup has custom dialogs with inputs like textBoxes. Each TextBox has associated a variable with a default value. The package kit contain also an .xml file wich is generated by installer and has in it the values setted in wizard in a specific path. That works very well.
The problem is I have a lot of this textBoxes and a lot of steps. I want to add the possibility for a user to browse an .xml file in one of the wizard's steps and then skip all the steps to insert data in textboxes.
I guess that inside my installer's project I have to set the default values for each variables with a value or with a path (I know exactly where the value I need is in xml) in condition that the user points to an xml.
I will ignore for now if the browsed xml has not the same template I need, let's say that I will find the paths.
The question is how I set the variables in my project in case that xml file is browsed?
Latest edit:
my xml looks like:
<Settings>
<SiteNames>
<Setting property="prop1">value1</Setting>
<Setting property="prop2">value2</Setting>
</SiteNames>
</Settings>
and my .js is:
function setValues(){
var xmlPath = Session.Property("IS_BROWSE_FILEBROWSED");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.load(xmlPath);
var elem = xmlDoc.getElementsByTagName("Setting");
for (var i=0; i<elem.length; i++){
Session.Property(elem[i].getAttribute("property")) = elem[i].childNodes[0].nodeValue);
}
}
It is something wrong? my property values are not changing..
The script is running when a button is pressed. I don't know what I have to do for this to work.
Thanks for your time.
You need a custom action that can use an XML DOM to read the XML file and call MsiSetProperty() to set your various properties.
For example:
<Settings>
<Setting Id="SOMEPROP1">SOMEVALUE</Setting>
<Setting Id="SOMEPROP2">SOMEVALUE</Setting>
</Setting>
Then it's just a matter of (pseudo code)
for each Setting element in Settings
MsiSetProperty( setting.ID, setting.InnerText )
next
Also MSI's internal native UI only has a directory browser not a file browser control so you will either have to keep the filename a constant and browse the directory or work the file selection control into your custom action also.
I give up with jscript function.. it didn't work.. I don't know why.
I use vbScript instead (is my first time :) I use vbscripts)
Dim xmlPath
Dim xmlDoc
xmlPath = Session.Property("IS_BROWSE_FILEBROWSED")
set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.load(xmlPath)
for each x in xmlDoc.getElementsByTagName("Setting")
Session.Property(x.getAttribute("property")) = x.text
next
It works very well!
Thanks for guiding me Christipher Painter!
Related
I'm using Microsoft Shell Controls And Automation COM library from VBA. I have a zip file and I am copying a file into the zip file. The problem is that the file already exists and it throws a dialog box which says "There is already a file with the same name in this location do you want to a) Copy And Replace or b) Don't copy". I would like to programmatically say Copy And Replace (overwrite!).
I think the equivalent on the .NET framework has a documentation page at http://msdn.microsoft.com/en-us/library/windows/desktop/ms723207%28v=vs.85%29.aspx
but I have tried a variety of these.
Also, I will accept removing the original item so that the addition succeeds with no problem; sadly I could not find a delete item method.
I am using Windows 8, 64 bit edition. I'm in Excel (14) VBA (7) and the library I'm using is at C:\Windows\SysWOW64\shell32.dll
Here is head of IDL of the type library I'm talking about
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: shell32.dll
[
uuid(50A7E9B0-70EF-11D1-B75A-00A0C90564FE),
version(1.0),
helpstring("Microsoft Shell Controls And Automation")
]
library Shell32
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
My preferred answer is the use the MoveHere method to move the old one out the way before adding. That way no dialog box is thrown. Thanks all.
Here's how you can delete a file from a zip using Shell:
Sub DeleteFromZip()
Dim fldr, zpath, itm, vrbs, vrb
zpath = "C:\_stuff\test\test.zip"
Set fldr = CreateObject("Shell.Application").Namespace(zpath)
For Each itm In fldr.items
If itm.Name = "IMG_0000322_2014.03.11.jpg" Then
itm.invokeverb "Delete"
Exit For
End If
Next itm
End Sub
This does raise a confirmation dialog though - see this link for how to avoid it:
FolderItem.InvokeVerb("Delete") without confirmation
Recently I discovered about .xlam files to reuse functions that I use in several files. I'm not a programmer so this is maybe something easy but I've been hours into this and I can't find the way to solve it.
I've just created a project with some of the functions that I used most and I saved the file in a Sharepoint site. After that I created a Reference and everything seems to be working well. I can Call functions just with a
call FunctionName()
And the functions are running well. But I haven't found the way to return global variables from the .xlam file to my .xlsb file
I'm defining a Global variable just like this in a Module in the .xlam
Global CRegion As String
In the same module I have this easy macro:
Function GetRegion()
CRegion = Range("B2").Value
End Function
And then in my .xlsb file Im testing something like this after calling the GetRegion Function.
Msgbox CRegion
The result is an empty Message Box. I've tried to define a global variable with the same name in my .xlsb file and it still does not work.
¿Any clue to solve this?
Have not tested it, but try:
To make a public variable available to other workbooks, from a new workbook select the workbook containing the public variable in the Available References box of the References dialog box (from a module sheet, click References on the Tools menu).
Source: MSDN
http://support.microsoft.com/kb/141693
I had a very annoying problem, I have found a solution, but I would like to ask you why it behaves like that...
I am using Visual Studio 2012 with TFS 2012. Everything was fine, but one day I have spotted a problem. When I have added a new project to my solution, then I have always obtaining this message every time I have reopened the solution:
This project file ... is not bound to source control, but the solution contains source control binding information for it. Do you want...
Whatever I have done, I still have this message. In the File->Source Control->Advanced->Change Source Control...' window every thing was fine. The *.vspscc files where properly created with good content. I was removing the binding and adding it again and again, but it was not helpful. All the time I had this annoying message...
And then I have spotted one difference in the *.csproj files. My problematic project did not have the following XML data:
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
When I have added those lines, problem was solved...
Is there anyone who can tell me why those elements where missing and why they cause such never-ending problem with annoying message about solution binding?
Thank you
This happens because the Solution file has the Source Control Information in it and the .csproj file will just implement what the solution file tells it.
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
The SAK referes to "Should Already Know" as it pulls the information from the solution file.
The solution file should contain something similar to what is shown below
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 4
SccEnterpriseProvider = {3BA58AB2-18FA-4F8D-95D4-32DDF27D184A}
SccTeamFoundationServer = http://TFSSERVER:8080/tfs/DPC
SccLocalPath0 = .
SccProjectUniqueName1 = Project1\\Project1.csproj
SccProjectName1 = Project1
SccLocalPath1 = Project1
SccProjectUniqueName2 = Project2\\Project2.csproj
SccProjectName2 = Project2
SccLocalPath2 = Project2
SccProjectUniqueName3 = Project3\\Project3.csproj
SccProjectName3 = Project3
SccLocalPath3 = Project3
SccProjectUniqueName4 = Project4\\Project4.csproj
SccProjectName4 = Project4
SccLocalPath4 = Project4
EndGlobalSection
Now what can happen is that if the person first checking in the solution and projects doesn't include the Solution.vssscc file then Visual Studio can't determine the source control. if this occurs delete the vssscc file and close the solution. reopening the solution will create a new vssscc file, ensure this gets checked back into source control.
Another thing to check when adding a project make sure that the solution file gets checked out and then checked back in again when you submit the project.
As long as the solution file and vssscc file are handled correctly by source control then when you add a new project it should pick up the source control settings from the solution file and then apply the SCC Nodes to the new project
I wat to save a file.I use this.
FileChooser fileChooser = new FileChooser();
File file = fileChooser.showSaveDialog(null);
But in the dialog I want to suggest a name for the file, so that the user only selects a directory for the given file.The name of the file is known already.So i want to suggest that filename.
ThankYou.
This is now fixed in Javafx 2.2.45 (bundled with java 7.0_45 now) and you can do what the OP is suggesing with the following property of fileChooser, setInitialFilename, used as such:
FileChooser myFile = new FileChooser();
myFile.setInitialFileName("Whatever_file_I_want.coolFile");
Now, I don't think there is anyway to STOP the user from choosing a different file, but at leas this will give them a default you want them to pick.
Initial file name providing - it is a thing, which requires to transfer your string (initial name) through native call, to the call of the native file chooser. It is a complex thing, and you can look at these issues about its implementing :
http://javafx-jira.kenai.com/browse/RT-16111 (main one)
http://javafx-jira.kenai.com/browse/RT-24588
http://javafx-jira.kenai.com/browse/RT-24612
They all have fix version lombard, so, they are fixed in JDK 8.
So, you can specify initial file name for a file, starting from JDK 8 (you can access it, downloading JDK early access).
Recently, I've tested this feature, and it is working.
There is a method setInitialName() or smth like that.
And, as I've mentioned, it is a complex thing, and you are not likely to be able to implement it by yourself (until you are able to build jfx).
So, the decision - to wait until JDK8 release, or to use early access builds. Or, to use your own implementation of file chooser.
Here's a workaround that worked for me:
you can use javafx.stage.DirectoryChooser to select a directory for the file you want to save and after saving create a new file in this directory with the default name and extension.
DirectoryChooser dc = new DirectoryChooser();
File file = dc.showDialog(null);
if (file != null) {
file = new File(file.getAbsolutePath() + "/dafaultFilename.extension");}
I want to know how to dynamically assign file name using Log4net .My application is such that 10 different files should be dynamically created based on user input ,and later based on the name the corresponding file name needs to be picked up and information written to it
For example in my application based on my buisness requirement for every xml file a corresponding log file with the same name as xml file should be created .Later whenever I do any modification to the xml file an entry needs to be in the corresponding log file
Please help . I having trouble to get control of the appropriate log to write it
Have not done this, but there are probably a number of ways of doing this, so this may not be the best way, but it should work
public OpenLogFile(string fileName)
{
log4net.Layout.ILayout layout = new log4net.Layout.PatternLayout("%d [%t]%-5p : - %m%n");;
log4net.Appender.FileAppender appender = new log4net.Appender.FileAppender(layout , filename);
appender.Threshold = log4net.Core.Level.Info;
log4net.Config.BasicConfigurator.Configure(appender);
}
Then just call OpenLogfile when you need to switch files.
You might need to tweak the layout or appender type.
A big disadvantage of this method is you losing the xml configuration and the ability to change settings at runtime. So a better way might be to configure your appender in the xml file to use a property
eg
file type="log4net.Util.PatternString" value="Logfiles\Log_For_%property{MyLogFileName}"
Then in your code you could change the property
log4net.GlobalContext.Properties["MyLogFileName"] = ...;
The tricky bit is to get log4net to reload itself. I haven't read the documentation of this, so I don't know if there is a way of forcing a reload. It might work if you just call log4net.Config.XmlConfigurator.ConfigureAndWatch again. Otherwise it should work if you opened the xml file and saved it again (without needing to change anything)
Hope this helps.