jump to navigation

Deploying scripts with SCE June 2, 2008

Posted by Björn Axéll in How-To, SCE.
comments closed

I have seen allot of questions in the forums and news groups if SCE can deploy scripts – and the answer is Yes. The last week, me and my Ty from the SCE products team has done some tests. Here is a sample where we have a vbs script that copy files.

  1. Create a vbs script (call it Copy.VBS for this example)
  2. Dim oFS
    Dim oShell
    Dim strDestDir
    Set oShell = CreateObject(”WScript.Shell”)
    Set oFS=CreateObject(”Scripting.FileSystemObject”)
    strDestDir=oShell.ExpandEnvironmentStrings _
    (”%ALLUSERSPROFILE%”) + “\”
    If oFS.FolderExists(”SourceFiles”) Then
    On Error Resume Next
    'Copy the files
    oFS.CopyFolder “SourceFiles”, strDestDir
    'If there was an error copying the files, quit with the specific error code
    If Err.Number <> 0 Then
    End If
    ‘Exit with file copied, if no error occurred
    End If
    ‘Exit without Success
    WScript.Quit (1)

  3. Create a working folder, and store within it the following files:


    b. Working Directory

    c. Copy.VBS (from above)

    d. Place any needed files within the SourceFiles directory


  4. Create a new software distribution package within System Center Essentials

    a.Package setup file: browse to the cscript.exe location from step #1

    b.Command line parameters: -nologo copy.vbs


  5. Deploy the package to the appropriate managed machines


  6. Review the desired result


When the package is deployed, the Windows Update Agent will call into Cscript.exe, and that program will reference the script which is located in the same working directory. Your end users will see a “flash” of a CMD window briefly while the script is executing.


Like with any other package, this one will execute in the context of the user unless it is launched from any of the following installation actions:

· Install-at-shutdown

· Scheduled installation

· Deadline installation

If your script requires to be in the user context, it is important to mark “requires input from the user during installation”. This flag will prevent execution in the above installation actions.

I want to thank Ty for helping me validating this scenario