I am new to writing vbscript and was wondering if anyone knows of a good resource that can help in making changes to the wsi via a vbscript or the Macro function in WfWI?

I have been trying to do the following:

I am trying to change the SourcePath column in the WiseSourcepath table, from [ProgramFiles] to a relative path ".\Source\". My directory structure is like this:

Project Folder
\Dev
Project.wsi (file here)
\Source file(s) here

I can read the rows in make the modification but then it seems to write but the wsi is not changed.

Function ProjectWSP()
Set tblWSrcPath = objWfWI.WTables("WiseSourcePath")
Set rowwsp= tblwsrcpath.NewWRow
rowwsp.WColumns("File_").Data="TESTFILE"
rowwsp.WColumns("SourcePath").Data="TESTPATH"
rowwsp.WColumns("Date").Data=1062129600
rowwsp.WColumns("Attributes").Data=0
tblWSrcPath.WRows.AddRow rowwsp
Exit Function
For Each rowWsp In tblWSrcPath.WRows
If Left(rowWsp.wcolumns("SourcePath").Data,14)="[ProgramFiles]" Then
tTest=".\Source\" & Right(rowWsp.wcolumns("SourcePath").Data,Len(rowWsp.wcolumns("SourcePath").Data)-14)
rowWsp.wcolumns("SourcePath").Data=tTest
' MsgBox rowWsp.wcolumns("SourcePath").Data

End If
Next



Any help would be greatly appreciated.

Mike -
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Hi Mike,

I've posted a solution for you at the Altiris forum.
Answered 03/22/2007 by: AngelD
Red Belt

Please log in to comment
0
AngleID,

Can you tell me how I would run a query against AD in the Wise Macro? I have it as a function in my vbscript but when I past it in the macro it gives my a message "Syntax error" Source line: Function GetpackagerName(StrUserName).

I have also added my code.

Sub AddSummaryinfo

'This adds DTE information to the MSI Summary Information.

Dim objShl
Dim arAdinfo, strUserName, strContact, strChkValue, strAuthor, strAuthorDif, strResponse
Dim strConsultant, rowSumry

Set objShl = CreateObject("WScript.Shell")

strChkValue = 0
strAuthorDif = 0
strConsultant =0

strUserName = objShl.ExpandEnvironmentStrings("%USERNAME%")

If strUserName = "mpNTID" Then
strResponse = MsgBox("Are you packaging for your self?",4 ,"Helping Packagers")
If strResponse <> 6 Then 'User select "yes"
strResponse = InputBox("Enter the Number next to your name:" &_
vbCrLf & "1 - " & "LName, Alex C." &_
vbCrLf & "2 - " & "LName, Tom C." &_
vbCrLf & "3 - " & "LName, Todd E." &_
vbCrLf & "4 - " & "LName, Jonathan R." &_
vbCrLf & "5 - " & "LName, John R.")


Select Case strResponse
Case "1"
strUserName = "acNTID"
Case "2"
strUserName = "tcNTID"
Case "3"
strUserName = "teNTID"
Case "4"
strUserName = "jrNTID"
Case "5"
strUserName = "jrNTID"
End Select
End If
'Add consultanst USERID here for packaging
ElseIf strUserName = "rcNTID" then
strConsultant = 1
ElseIf strUserName = "lbNTID" then
strConsultant = 1
End If

Set arAdinfo=GetPackagerName(strUserName)
Set tblSummary = WTables("Summary")

For Each rowSumry In tblSummary.WRows
If rowSumry("Field") = ("Comments") Then
If InStr(1, rowSumry("Value"), "ontact:")>1 Then
strChkValue = 1
End If
End If
Next

If strChkValue = 0 Then
For Each rowSumry In tblSummary.WRows
If rowSumry("Field") = ("Title") Then
rowSumry("Value") = strPkgFileName
ElseIf rowSumry("Field") = ("Author") Then
rowSumry("Value") = arAdinfo("Name")
ElseIf rowSumry("Field") = ("Comments") Then
rowSumry("Value") = "Contact: Desketop Engineer -" &_
vbCrLf & arAdinfo("Email") &_
vbCrLf & "x-" & arAdinfo("Phone")
End If
Next
Else
For Each rowSumry In tblSummary.WRows
If rowSumry("Field") = ("Title") Then
rowSumry("Value") = strPkgFileName
ElseIf rowSumry("Field") = ("Author") Then
strAuthor = rowSumry("Value")
If strAuthor = arAdinfo("Name") Then 'Checks that pacakger Name is different
rowSumry("Value") = arAdinfo("Name")
Else
strResponse = MsgBox("Would you like to change the current Packager Info(" & strAuthor & ")to your Info?", 4, "Pacakger Info.")
If strResponse = 6 Then 'User selected "Yes".
strAuthorDif = 1
rowSumry("Value") = arAdinfo("Name")
End If
End If
ElseIf rowSumry("Field") = ("Comments") Then
If strAuthorDif = 1 Then
rowSumry("Value") = "Contact: Desketop Engineer -" &_
vbCrLf & arAdinfo("Email") &_
vbCrLf & "x-" & arAdinfo("Phone")
ElseIf strConsultant = 1 Then
rowSumry("Value") = "Contact: Desketop Engineer -" &_
vbCrLf & "MPNTID@xxx.com" &_
vbCrLf & "x-" & "nnnn" &_
vbCrLf & "Packaged by a consultant"
End If
End If
Next
End If

MsgBox arAdinfo("Name")
MsgBox arAdinfo("Phone")
MsgBox arAdinfo("Email")

'//////////////////////////////////////////////////////////
'Get Packagers Information from AD
Function GetPackagerName(strUserName)
Dim objConn, objRS, objUser, strTelephoneNumber, aADSInfo, adsroot, ads, sSQL
Set aADSInfo=CreateObject("Scripting.Dictionary")
Set ADS = GetObject("LDAP://rootDSE")

adsroot=ads.Get("defaultNamingContext")

Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "ADs Provider"
sSql = "<LDAP://" & adsroot & ">;(samaccountname=" & strUserName & ");distinguishedname,ADsPath;subtree"
'MsgBox ssql
Set objRS = objConn.Execute(sSQL)

Set objUser = GetObject(objRS("adsPath")) ' or objRS.Fields(0) - same thing
aADSInfo("Name")= objUser.DisplayName
aADSInfo("Phone")= objUser.telephoneNumber
aADSInfo("Email")= objUser.mail

Set GetPackagerName=aADSInfo

Set objUser = Nothing
Set objRS = Nothing
Set objConn = Nothing
End Function

End Sub
Answered 05/08/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
Seems that you are nesting the function withing the sub.
Try:

Sub AddSummaryinfo
...
End Sub

Function GetPackagerName
...
End Function
Answered 05/08/2007 by: AngelD
Red Belt

Please log in to comment
0
I tried that, but it seems the Wise Macro Editor will not let you do things outside the sub routine.

Can I make a call to another sub routine within a sub routine? That is what I am going to test next.

Thank you, for all your help.

I am trying to learn how to use the Macro Editor. Is there any tool that you use that is better?
Answered 05/09/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
I make great use of the Wise Macro editer. Converting the WiseSourcePath in the wsi is one of my manual macros.

Please feel free to use it.

Sub ConvertWiseSourcePathPropertiesRelative
Dim tblWiseSourcePath : Set tblWiseSourcePath = Wtables("WiseSourcePath")
Dim rowSource
For Each rowSource In tblWiseSourcePath.WRows ' process each row in WiseSourcePath table
If instr(rowSource("SourcePath"), "[ProgramFiles]") <> 0 Then
rowSource("SourcePath") = Replace(rowSource("SourcePath"), "[ProgramFiles]", ".\Source\Program Files\")
End If

If instr(rowSource("SourcePath"), "[WindowsFolder]") <> 0 Then
rowSource("SourcePath") = Replace(rowSource("SourcePath"), "[WindowsFolder]", ".\Source\Windows\")
End If

If instr(rowSource("SourcePath"), "[SystemFolder]") <> 0 Then
rowSource("SourcePath") = Replace(rowSource("SourcePath"), "[SystemFolder]", ".\Source\Windows\System32\")
End If
Next
Set tblWiseSourcePath = Nothing
msgbox "Process Copleted", vbOkonly, "Convert WiseSource Path Properties Relative"
End Sub
Answered 05/09/2007 by: Robo Scripter
Orange Senior Belt

Please log in to comment
0
Robert,

I have that sub routine already, but thank you.

I need to figure out how to Run my AD function in Macro Editor. Can you help me with that. I hear you are pretty savvy. We have some mutual packaging friends, Rick Daniels and Randy Conrad.

P.S. Randy and I working together on this project.

Thanks,
Answered 05/09/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
just thinking a laterally a little here but wouldn't it be easier and cleaner to use a lookup table in your macro.

ie

select case strUserName
case "userA"
strPhone = xxxx
strEmail = xxxx
strNam = xxxx
case "userB"
strPhone = xxxx
strEmail = xxxx
strNam = xxxx
end select

if you insist on heading down the AD lookup path you are better served using the name.translate function which will convert a userid id into an Adspath with the ADoDB SQL query.
Answered 05/09/2007 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
Greetings Mike.

Tell the guys hello.

AngelD was correct in that the only thing wrong with the Sub is the nested function.

Do this:
1. Open the Macro editor to edit the "AddSummaryinfo" macro.
2. Cut the "GetPackagerName" function from the Sub.
3. On the macro editor secondary toolbar select the "Full Mode View" button.
4. Change the far right pull down to "(Declarations)" section.
5. Paste the function above the " 'End of (Declarations) " text.
6. Save and run the macro.

It seems to work fine for me

Without making any other changes it populates the Author field as well as populating the Comments field with the required data.

[8D] Nice I think I will hold on to it if you don't mind. [;)]
Answered 05/10/2007 by: Robo Scripter
Orange Senior Belt

Please log in to comment
0
jmcfadyen,

I did not want to have multiple places to change information like user delta. But thank you.

Robert,

Thank you so much for the detailed fix. Yes, you may use this and any one else that would like to. It's my way of giving back to the community that has help me so many times.

Thank all,
Answered 05/10/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
Here is another issue:

In my vbscript I was passing the Wise project variables to set some fields, like Summary table/Title to [ProjectName].

Do you know if it is as simple as adding the brackets and variable or do you have to declare a call or stay with my vbscript and populate the property table with these values?

Example:

Create a tool in WPS Tool to run WScript.exe
Create a Task (Company Branding) that uses the WScript.exe tool.
Create the following Options to run my vbscript and pass the switches to the (vbs) script with the following options.


Task Name: Company Branding
Tool: WScript.exe
Option: MST Branding
Name: MST Branding
"[Sharepoint]\VBScripts\Branding\Add_Branding_2.0.vbs" /PJDR="[ProjectDir]" /PDV="[ProductVendor]" /PKFN="[FileName]" /PJN="[ProjectName]" /MSTB


My vbs file checks these switches and sets variables accordenly. (/PKFN="Adobe_AcrobatPro_8.0_B01" SETS strPkgFileName = "Adobe_AcrobatPro_8.0_B01")
Answered 05/10/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
I'm not sure I understand what you mean, could you elaborate abit?
Answered 05/10/2007 by: AngelD
Red Belt

Please log in to comment
0
I would do like this:
Added a task
Type: Other EXE
EXE: C:\WINDOWS\system32\wscript.exe
Option: "[Sharepoint]\VBScripts\Branding\Add_Branding_2.0.vbs" /PJDR:"[ProjectDir]" /PDV:"[ProductVendor]" /PKFN:"[FileName]" /PJN:"[ProjectName]"

From the vbscript I would have something like this to fetch the arguments for usage when opening/modifying the project file:
Option Explicit
Dim WSIFile, WFWI, WTable

WSIFile = Wscript.Arguments.Named("PJDR") & "\" & Wscript.Arguments.Named("PKFN") & ".wsi"

Set WFWI = CreateObject("WfWi.Document")
WFWI.Open(WSIFile)

Set WTable = WFWI.WTables("Summary")
WTable.WRows.Row("Title").WColumns("Value").Data = "Installation Database"
WTable.WRows.Row("Subject").WColumns("Value").Data = Wscript.Arguments.Named("PJN")
WTable.WRows.Row("Author").WColumns("Value").Data = "<Name from Active Directory>"
WTable.WRows.Row("Key Words").WColumns("Value").Data = "Installer,MSI,Database"
WTable.WRows.Row("Comments").WColumns("Value").Data = "This installer database contains the logic and data required to install " & WFWI.GetProperty("ProductName") & " " & WFWI.GetProperty("ProductVersion") & "."

WFWI.Save(WSIFile)
Answered 05/10/2007 by: AngelD
Red Belt

Please log in to comment
0
AngleID,

I have this already in my vbscript. I am trying to move it from the vbscript to a Wise Macro to run it from the macro instead. I am looking for, how to retrieve the the WPS variables ([PackageName], [FileName], [ProjectDir] etc....) from with in the wise macro.

Just thought there might be an easier way.

Any help on this would be greatly appreciated.

P.S. I am currently having the vbs branding script add these WPS variables as properties so when I open the wsi/mst project, the macro will run using the properties.
Answered 05/11/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
I have decided to use the vbscript to create the properties and have the macro get the properties values.

Thanks all, for your help.
Answered 05/11/2007 by: MPA2012
Senior Yellow Belt

Please log in to comment
0
Thats great, as I'm the wrong person to ask about Wise Macro scripting [:D]
Answered 05/11/2007 by: AngelD
Red Belt

Please log in to comment
0
If it's of any help I found this piece of information laying around at my disk:

Q.
How to get the "Package Path" or actual opened wsi including full path in a Wise Installer Editor macro (visible on Project Definition / Product Detail / Package Path and also declared via [ProjectDir] in Project Setup Dialog)?

A.
Have a look at the save event, you will see a property called "Pathname". Throw that into the declarations then, chop it up using string manipulation as this is a full file path.
Answered 05/11/2007 by: AngelD
Red Belt

Please log in to comment
0
Mike,

Sorry I didn’t get back to you on this, I got more than a little busy.

[:(] Unfortunately WPS does not directly expose and of the project data items internally to the interior of the WSI. Therefore there is no easy way to access these values via the Wise Macro. [:(]

[:@]((NOTE: To any Altiris folks reading this... This is a BAD thing. Fix it please!))[:@]

I have in the past attempted to access the data utilizing WMI calls directly back to the Work Bench database but the project was cut short for cost concerns.

We currently have in our project work flow a vbscript action that utilizes the same method of branding. The difference being that here we create a component that writes an INI file as well as a set of defined registry entries.

As far as what can and can not be done with the Wise Macro. I am currently running a macro that has around 70 separate functions that can touch virtually every part of the development process in WSI’s, MSI’s, MST’s as well as merge module development and patch creation.

Couple this with a library of over 3000 vbscript and there is very little I have not found a solution to.

Regards,
Answered 05/11/2007 by: Robo Scripter
Orange Senior Belt

Please log in to comment
0
If you have define the Application field (PackageName) under "Product Details" (found under the Installation Expert view) you could from a macro get the value from the WiseMediaOptions table.

Set tblWiseMediaOptions = WTables("WiseMediaOptions")
sPackageName = tblWiseMediaOptions.WRows.Row("SMApplication").WColumns("Value").Data
Answered 05/11/2007 by: AngelD
Red Belt

Please log in to comment
0
Have in mind that this is my first Macro so be gentle [;)]

Edit the Save macro for "On Windows Installer Editor Event" (WFWIEvents_Save)
This code should be similar for what you're after:

sProjectDir = Mid(strPathname, 1, InStrRev(strPathname, "\")-1)
sProductVendor = GetProperty("Manufacturer")
sFileName = Mid(strPathname, InStrRev(strPathname, "\")+1)
sFileName = Mid(sFileName, 1, InStrRev(sFileName, ".")-1)

Set tblWiseMediaOptions = WTables("WiseMediaOptions")
sSMApplication = tblWiseMediaOptions.WRows.Row("SMApplication").WColumns("Value").Data
sSMPackage = tblWiseMediaOptions.WRows.Row("SMPackage").WColumns("Value").Data
sProjectName = sSMApplication & " " & sSMPackage

MsgBox(sProjectDir & vbNewline & sProductVendor & vbNewline & sFileName & vbNewline & sProjectName)
Answered 05/11/2007 by: AngelD
Red Belt

Please log in to comment
0
It got abit late when I did this last night and don't think the value of sProjectName will be correct for you.
Don't know if it's possible to get the value of ProjectName from the Project Setup windows.
Answered 05/11/2007 by: AngelD
Red Belt

Please log in to comment
0
Therefore there is no easy way to access these values via the Wise Macro.

umm sorry I have been away for a bit.

are you guys just looking for the project directory ?

if so

(pathname)

its in the save event, this will return the full path to the current WSI / MSI folder.

its been there since the year dot but its poorly documented.
Answered 05/13/2007 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
Actually pathname will return the full path to the WSI or MSI file and not the folder. That's why my previous posted code had to chop the filename off including the last "\".
Answered 05/14/2007 by: AngelD
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity