Delete files VBSCRIPT With exit codes to implement on sccm 2012 deployment


Hi to all

Today  I’ll post a Vbscript that is able to send Info to Sccm2012 deployments on the “monitoring” space you will be able to read the messages depending of the exit code that you have used

First , you can get entire codes here

Once you have the codes , let’s begin with a simple “delete files script”, this simple script deletes a file on the  user profile

The trick is on the wscript.quit(0) where wscript.quit(Error code what you want) , will able you to handle what happened when you launch the script , nice right ? 😀

Sccm will show you on the monitoring the code what you writed on the script

Set objNetwork = CreateObject(“Wscript.Network”)
” Script shell
Set oShell = CreateObject(“WScript.Shell”)
” Filesistem object
set filesys=CreateObject(“Scripting.FileSystemObject”)

” if exist function
function folder_exist (folder)
dim returnvalue
If filesys.FolderExists(folder) Then
returnvalue = “true”
returnvalue = “false”
End if
folder_exist = returnvalue
End function

” get the user profile
strHomeFolder = oShell.ExpandEnvironmentStrings(“%USERPROFILE%”)
folderx = “\AppData\Local\Cisco\Unified Communications\Jabber\CSF\Contacts”
folder = strHomeFolder & folderx
” If folder doesn’t exist  I exit and wscript returns OK ,we won’t do anything

if (folder_exist(folder) = “false”) then
”error code ”
end if

” If the  folder exist i will delete and show another code

Set folderdelete = filesys.GetFolder(folder)
if (folder_exist(folder) = “true”) then
end if
” checking of the delete
if (folder_exist(folder) = “false”) then
” ok
” If there is a error i will return code 1603

end if

remember the other trick  : To run the script on a deployment must use the option ” RUN PROGRAM FROM DP” lal

Have a nice day !!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s