Jump to content


raha_ang

How do I create a package that contains a CMD and RUN command?

Recommended Posts

Hey Guys!!!

 

I apologise in advance if this is a stupid question, I'm quite new to this stuff so please go easy on me :D

 

I have been given the task of rolling out a software upgrade for a piece of company software.

 

Basically what needs to happen is (in this order):

 

1. Install a file from an MSI ( I have been given the MSI file which is in the SMS server package store )

2. Run this script "C:\Windows\System32>MsiExec.exe /x {205CFDD2-34CF-4141-93AA-55FCDB7BB012} /q" (uninstalls the old one)

3. Run this RegKey file "regedit.exe /s \\aumxxxxxxxxx\smspkgg$\xxxxxxxx\settings.reg" (Adds the server settings to the new one - ATTACHED)


Is there anyway to compile all these steps into one package where it can follow these steps?

 

There are also 2 .mst files in the folder which im unsure of how to open to see what they are.

 

Let me know if you need any further information.

Settings - ANG.txt

Share this post


Link to post
Share on other sites

Hi

 

Do a search on Google for SCCM Task Sequence's, there is plenty to read and they can do far more than the normal advertisements

 

Awesome thanks Keith, will do!

 

oO

 

Just create a script in your favorite language (DOS Batch, VBScript, ...) and run it from your Package/Program command line :

 

- Batch: cmd.exe /C FileName.bat

- VBScript: wscript.exe FileName.vbs

 

Havent done much work with scripting before hence why I said im new to this stuff and came here to ask ;)

Share this post


Link to post
Share on other sites

oO

 

Just create a script in your favorite language (DOS Batch, VBScript, ...) and run it from your Package/Program command line :

 

- Batch: cmd.exe /C FileName.bat

- VBScript: wscript.exe FileName.vbs

When I run the BAT file on the machine locally, CMD appears for a brief second and then closes and shortly after an icon appears called MsiExec.exe

 

After that nothing happens and the program does not appear in the add remove programs as it should.

 

Any ideas?

 

C:\Windows\System32>MsiExec.exe /i "\\SERVERNAME\smssource$\Roomview Fusion\OutlookAddinSetup.msi" /qn /norestart /log "C:\Program Files\XXX\logging\FusionTest2.log"

 

C:\Windows\System32>MsiExec.exe\MsiExec.exe /x {205CFDD2-34CF-4141-93AA-55FCDB7BB012} /q

 

regedit.exe /s \\SERVERNAME\smspkgg$\XXX0028B\settings.reg

 

Share this post


Link to post
Share on other sites

How about this:

 

msiexec /i "%~dp0OutlookAddinSetup.msi" /qn /norestart /log "C:\Program Files\XXX\logging\FusionTest2.log"

msiexec /x {205CFDD2-34CF-4141-93AA-55FCDB7BB012} /q

regedit.exe /s %~dp0settings.reg

 

 

have all of the files in one folder including the batchfile that executes it. To test have it on a share and UNC to it and run the batch file. If it works create a package/application from it. The program command line will be the name of the batch file that executes the installs!

Share this post


Link to post
Share on other sites

Hey Rocket Man,

 

Thanks for the reply.

 

Still no luck.

 

This is the VBS script that I was left with that doesnt work. It installs the new software but I dont think it does it in the right order so it doesnt work.

 

- Install new version

- Uninstall old version

- Add reg settings

 

-----------------

 

Option Explicit
Dim ObjShell, ReturnVal, ExistingVersion, ProductCode, objWMIService, objProcess, colProcess, ProcessesFound, temp, x, ProductNameTemp
Set ObjShell = CreateObject("WScript.Shell")
KillProcess("outlook.exe")
install


x= 0
Dim ProductName(0)
ProductName(0) = "Crestron RoomView Outlook Addin"


KillProcess("outlook.exe")

'Set ObjShell = CreateObject("WScript.Shell")

For x=0 To UBound(ProductName)
ProductNameTemp = ProductName(x)
If Uninstall(GetProductCode(ProductNameTemp,32),ProductNameTemp,32) = "" Then
If Uninstall(GetProductCode(ProductNameTemp,64),ProductNameTemp,64) = "" Then
'Error
End If
End if
Next



wscript.quit(ReturnVal)

Function Uninstall(ProductCode, ProductName, Regtype)
On Error Resume Next
Dim ExistingVersion
If ProductCode <> "" Then
ObjShell.LogEvent 4, "Found " & ProductName & " - " & ProductCode & " in " & Regtype & "-Bit"
ReturnVal = ObjShell.run ("Msiexec.exe /x " & ProductCode & " /qn reboot=reallysuppress /lve " & Chr(34) & "C:\Program Files\GPT\logging\Uninstall -" & ProductName & ".log" & Chr(34), 1, True)
If Not (ReturnVal = 0 Or ReturnVal = 3010) then LogError("Could not Uninstall " & ProductName & "!")
Uninstall = ReturnVal
Else
ObjShell.LogEvent 4, "No product code supplied for product: " & ProductName & " - in " & RegType & "bit , no search will be done"
End If
End Function

Function GetProductCode(strName,Regtype)
Dim oCtx, oLocator, oReg, oInParams, oOutParams, arrValueNames, strValue, key, i, newkey
Const HKEY_LOCAL_MACHINE = &H80000002
Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", Regtype
Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
Key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

oReg.EnumKey HKEY_LOCAL_MACHINE, Key, arrValueNames

For I=0 To UBound(arrValueNames)
newkey = key & "\" & arrValueNames(I)
oReg.GetStringValue HKEY_LOCAL_MACHINE,newkey,"DisplayName",strValue
Dim temp1
temp1 = InStr(LCase(strValue), LCase(strName))
If InStr(LCase(strValue), LCase(strName)) > 0 Then
If InStr(LCase(strValue), LCase(strName)) = 1 Then
oReg.GetStringValue HKEY_LOCAL_MACHINE,newkey,"UninstallString",strValue
If strValue <> "" Then
GetProductCode = Replace(Replace(Replace(Replace(UCase(strValue), "MSIEXEC.EXE /X",""), "MSIEXEC.EXE /I",""), "MSIEXEC /X",""), "MSIEXEC /I","")
ObjShell.LogEvent 4, "Uninstall String Found: " & GetProductCode
End If
End If
End If
Next
End Function

Function LogError (Message)
ObjShell.LogEvent 1, "Installation Error: " & Message & " MSI Return Code: " & ReturnVal
WScript.Quit ReturnVal
End Function

Function install
ReturnVal = ObjShell.run ("msiexec /I ""OutlookAddinSetup.msi"" /qn /lve ""C:\Program Files\GPT\logging\RoomViewFusion.log""", 0, True)
If Not (ReturnVal = 0 Or ReturnVal = 3010) then LogError("RoomViewFusion! ReturnCode:" & ReturnVal)
'ReturnVal = ObjShell.run ("regedit /s settings.reg", 0, True)
'If Not (ReturnVal = 0 Or ReturnVal = 3010) then LogError("RoomViewFusion! ReturnCode:" & ReturnVal)
End Function

Function KillProcess(strProcess)

Dim Process, strObject, objProcess, IsProcessRunning, strComputer
IsProcessRunning = False
strComputer = "."

For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcess & "'" )
For Each objProcess in colProcess
objProcess.Terminate()
Next
Exit For
else
End If
Next

End Function

Function installShield
Dim strComputer, objReg, objWMIService, colItems, objItem, i, arrFind, strKeyPath, strEntryName, strValue
Const HKEY_CLASSES_ROOT = &H80000000
'On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DCOMApplicationSetting",,48)
For Each objItem in colItems
If objItem.Description <> "" Then
arrFind=Split(objItem.Description)
For i=0 To UBound(arrFind)
If lcase(arrFind(i))="installshield" Then
strKeyPath = "AppID\" & objItem.AppID
strEntryName = "RunAs"
strValue = ""
objReg.DeleteValue HKEY_CLASSES_ROOT,strKeyPath,strEntryName
End If
Next
End If
Next

End Function

Share this post


Link to post
Share on other sites

For a new you version , you would have msi.

so create a program for that msiexec /i "application" /qb!

 

For removing old version , create a script file which will check the product codes and remove and create another program with cscript "uninstall.vbs"

chain this previous program where this will run first and for registery create another program chain it with above prorgam.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.