none
run advertisements not under system context RRS feed

  • Question

  • I've noticed that when you choose "Whether or not a user is logged on" in the program environment, the program will run under system context. Is there anyway wherein the program will run under administrator context and will run whether or not a user is logged on?
    • Moved by TorstenMMVP, Moderator Monday, March 21, 2011 11:31 AM moved to the SDK subforum (From:Configuration Manager Software Distribution)
    Friday, March 18, 2011 12:46 PM

All replies

  • Not directly through software distribution. The only known way to control this is to use a single task task sequence with a run command line task; the run command line task (if you have R2/R3) allows you to specify alternate credentials.

    What task are you specifically trying to accomplish by doing this? Usually I find folks trying to do this because they don't fully understand the ins and outs of ConfigMgr and the best way to use ConfigMgr to get their task accomplished.


    Jason | http://myitforum.com/cs2/blogs/jsandys | http://blogs.catapultsystems.com/jsandys/default.aspx | Twitter @JasonSandys
    Friday, March 18, 2011 2:21 PM
    Moderator
  • Hi,

    I agree with Jason, in the cases where it has been absolutly necessary I have used the Task Sequence option and it has worked fine.
    Is it the requirement of the setup program which makes you want to run it as a local administraor?

    Regards,
    Jörgen


    -- visit my System center blog at http://ccmexec.com --
    Friday, March 18, 2011 4:22 PM
    Moderator
  • I have added a vbscript in my package that I need to run. The vbscript basically runs some packages that are optionally advertised. The problem is that the vbscript were not able to run the optional advertisements in system context. The script actually works when you double click it so I assumed that the script is having a problem when executed in system context. I am not sure if the solution above, running in ts, will work since the optional advertisements that will be executed is not completely silent.

    Monday, March 21, 2011 3:16 AM
  • It's usually no problem to run vbscripts in system context, but you have to consider that environment variables etc might not be the same as in a "standard" user context. We can't provide any help without knowing the contents of the script.
    Torsten Meringer | http://www.mssccmfaq.de
    Monday, March 21, 2011 7:25 AM
    Moderator
  • here is my script that runs optional sccm advertisements

     

    Dim oUIResource, objShell
    Dim oPrograms, strRegSearch, strRegSearch1
    Dim oProgram, programId, packageId, myProgram, arrProgram, arrPackageID, intCount
    Set objShell = CreateObject("Wscript.Shell")

    'arrProgram = Array("3.0.0 FORCE Install INSTALL PrintKey_510.MSI", "3.0.0 FORCE Install INSTALL Greenshot_06.MSI")
    'arrPackageID = Array("IIC00008", "IIC00005")

    'Validate connection to SCCM Client
    Set oUIResource = CreateObject ("UIResource.UIResourceMgr")
    If oUIResource Is Nothing Then
    'wscript.echo "Could not create Resource Object - quitting"
    WScript.Quit
    End If

    '=============================================================================
    'Begin Process
    '=============================================================================
    'Check existence of first application
    strRegSearch = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{AAE022C7-E7EB-485E-9BE8-1B3F7EC42B0C}\Displayname"

    If (RegValueExists(strRegSearch)) = "True" Then

     RunProgram "3.2.0 FORCE Remove INSTALL Greenshot_06.MSI", "IIC00005"
     
    End If

    'Check existence of second application
    strRegSearch1 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{51064134-5685-47B4-8A23-59CF96B08ED8}\Displayname"

    If (RegValueExists(strRegSearch1)) = "True" Then
     
     RunProgram "3.2.0 FORCE Remove INSTALL PrintKey_510.MSI", "IIC00008"
    End If


    Set oProgram=Nothing
    Set oUIResource=Nothing
    '======================================================================
    'Function
    '======================================================================

    Function RegValueExists (strRegValue)
     Dim objShell, strRegReadReturn
     Set objShell = CreateObject("Wscript.Shell")

     RegValueExists = True
     On Error Resume Next
     strRegReadReturn = objShell.RegRead(strRegValue)
     If Err.Number <> 0 Then
      RegValueExists = False
     End If
     On Error GoTo 0
     Set objShell = Nothing
    End Function

    '======================================================================
    'Routines
    '======================================================================

    Sub RunProgram(programId,packageId)
    On Error Resume Next

    'When was the program last ran?
    Set myProgram = oUIResource.GetProgram(programId, packageId)
    oldTime = myProgram.LastRunTime
    'WScript.Echo oldTime

    'Execute program
    'Wscript.Echo "Running program: " & programId & " " & packageId
    oUIResource.ExecuteProgram programId, packageId, True

    ' Wait for last ran to change...
    Set myProgram = oUIResource.GetProgram(programId, packageId)
    Do While myProgram.LastRuntime = oldTime
    Wscript.Sleep(1500)
    Set myProgram = oUIResource.GetProgram(programId, packageId)
    Loop
    'Wscript.Echo "Return Code: " & Err
    End Sub

    Monday, March 21, 2011 9:42 AM
  • Set oUIResource = CreateObject ("UIResource.UIResourceMgr")
    If oUIResource Is Nothing Then
    'wscript.echo "Could not create Resource Object - quitting"
    WScript.Quit
    End If
    Any chance that the script errors at that part? I think that this object cannot be created in system context, but I am not 100% sure right now ... Moving the thread to the SDK subforum.
    Torsten Meringer | http://www.mssccmfaq.de
    Monday, March 21, 2011 11:31 AM
    Moderator
  • no error was encountered in that part. the script was able to read the programId and packageID...
    Monday, March 21, 2011 12:25 PM
  • I have the same issue and find out that even running in TS with serviceUI.exe or executing it as a program without TS the script stops working at the point "oUIResource.ExecuteProgram programId, packageId, True".

    An error message will be displayed in execmgr.log

    I tried to run the script under user context and not under system. Furhtermore tried to set the sessionID to "1".

    Nothing helped.

    Running the script under the context of the user via double-clicking works fine!

    Any idea?


    Tarkan Koemuercue
    Wednesday, June 8, 2011 1:06 PM