Deployment Solution

 View Only
  • 1.  Help with getting a VBS script working in DS 6.9

    Posted Oct 26, 2011 08:24 AM

    Hi,

    We have a script which has been provided by a vendor. The script calls a stored procedure on a remote SQL database and removes a computer object.

    I want to run the script 'Locally on the Deployment Server' (6.9 SP5 MR1) and make use of the Altiris %COMPNAME% token.

    I can confirm the script runs if we run it outside of Altiris (E.g. Windows), but not within Altiris.

    NB: Our 'Altiris eXpress Server' service runs under the context of an Active Directory account which has appropriate rights to run the stored procedure on the SQL server.

    We have other VBS scripts which access other remote objects on different systems and these work fine.

    I'm wondering if anyone can help get this script working within Altiris DS, I think it needs amending...

    Thanks,

    RL

    '================
    ' Execute_BatchDelete.vbs (Execute the Machine_BatchDelete SP)
    ' Release v1.0
    ' ================

    Dim sDSN, SQLServer, SQLDB, NetBiosName, objShell

    'CONFIGURATION
    '================
    SQLServer = "SQL1"
    SQLDB = "DB1"
    '================

    Set objShell = CreateObject("WScript.Shell")
    Set objCommand = CreateObject("ADODB.Command")
    Set objParam = CreateObject("ADODB.Parameter")
    Set rs = CreateObject("ADODB.Recordset")
    sDSN = "Provider=SQLOLEDB;Data Source=" & SQLServer & ";Initial Catalog=" & SQLDB & ";Integrated Security=SSPI"
    NetBiosName = objShell.ExpandEnvironmentStrings("%COMPNAME%")

    objCommand.ActiveConnection = sDSN
    objCommand.commandtext = "Machine_BatchDelete"
    objCommand.CommandType = 4   'defines cmd type as stored proc
    Set objParm = objCommand.CreateParameter("@GroupName",200,1,256)         
    objCommand.Parameters.Append objParm
    Set objParm = objCommand.CreateParameter("@MachineNameFilter",200,1,64,NetBiosName)
    objCommand.Parameters.Append objParm
    Set objParm = objCommand.CreateParameter("@PreviewOnly",11,1,1,0)
    objCommand.Parameters.Append objParm
    set rs = objCommand.Execute



  • 2.  RE: Help with getting a VBS script working in DS 6.9
    Best Answer

    Posted Oct 26, 2011 08:33 AM

    Hey Rufusl

    Have you made this script as an embedded script or as a "run from location" script?

    If you made it as an embedded script you need to have:
    'vbscript

    as the first line, otherwise it will be created as a .cmd script.

    Kind Regards
    Morten Leth



  • 3.  RE: Help with getting a VBS script working in DS 6.9

    Posted Oct 26, 2011 10:25 AM

    Hi Morten,

    I've tried both methods. I've just added 'vbscript to the top of the script but still no cigar.

    There are no errors output from DS, so I'm not sure whats happening...



  • 4.  RE: Help with getting a VBS script working in DS 6.9

    Posted Oct 26, 2011 10:27 AM

    Scratch that - Amazing what a restart of the eXpress service does ;)

    I think your 'vbscript has done the trick :)

    Thanks Mortern!

    I'll mark your post as the answer :)



  • 5.  RE: Help with getting a VBS script working in DS 6.9

    Posted Oct 27, 2011 03:29 AM

    Hey Rufusl

    No problem, it's a good thing you got it solved. :)

    Kind Regards
    Morten Leth