Main menu

Post navigation

Deploying scripts with SCE

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.

Create a vbs script (call it Copy.VBS for this example)

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
WScript.Quit(Err.Number)
End If
‘Exit with file copied, if no error occurred
WScript.Quit()
End If
‘Exit without Success
WScript.Quit (1)

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

a. CSCRIPT.EXE

b. Working Directory

c. Copy.VBS (from above)

d. Place any needed files within the SourceFiles directory

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

Deploy the package to the appropriate managed machines

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.

Caveats:

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.