locked
how to merge 2 vbscript program into 1 RRS feed

  • Question

  • 1st program code:

    Dim objShell

    Set objShell = WScript.CreateObject("WSCript.shell")
    objShell.run """C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe"" /uninstall /qn"

    2nd program code:
    strFolderName = "C:\Program Files\Altiris"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(strFolderName) Then
    fso.DeleteFolder strFolderName
    End If


    prakash

    • Moved by Bill_Stewart Monday, April 6, 2015 9:49 PM Off-topic
    Friday, February 27, 2015 12:53 PM

Answers

  • This is not a Symantec Management (Altiris) support forum.

    For instructions on creating policies to uninstall the agent (or appropriate manual uninstall instructions), you need to find a more appropriate forum, which you should be able to find by searching.


    -- Bill Stewart [Bill_Stewart]


    • Edited by Bill_Stewart Friday, February 27, 2015 4:02 PM
    • Proposed as answer by Bill_Stewart Tuesday, March 3, 2015 3:10 PM
    • Marked as answer by Bill_Stewart Monday, April 6, 2015 9:48 PM
    Friday, February 27, 2015 4:02 PM

All replies


  • since they share no variable names, you can simply put one after the other.

    I think your question actually is: how to wait for the first part to complete.

    https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx

    Set objShell = WScript.CreateObject("WSCript.shell")
     objShell.run """C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe"" /uninstall /qn",,true
    
     strFolderName = "C:\Program Files\Altiris"
     Set fso = CreateObject("Scripting.FileSystemObject")
     If fso.FolderExists(strFolderName) Then
     fso.DeleteFolder strFolderName
     End If
    
    

    note I left out the dim statement. Dim declares a variable, but in vbscript, variables are declared automaticly when first used. For simple scripts that's enough.

    (For more complex scritps, use DIM for all your variables and enforce that using 'option explicit')

    https://msdn.microsoft.com/en-us/library/t7zd6etz(v=vs.84).aspx


    MCP/MCSA/MCTS/MCITP


    • Edited by SenneVL Friday, February 27, 2015 1:12 PM
    Friday, February 27, 2015 1:09 PM
  • You cannot wait on the installer.  It runs in the background.  You can poll with WMI to see when the process completes but most installers have two or more processes.


    ¯\_(ツ)_/¯

    Friday, February 27, 2015 1:34 PM
  • 1st program code:

    Set objShell = WScript.CreateObject("WSCript.shell")
    objShell.run """C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe"" /uninstall /qn"

    2nd program code:
    strFolderName = "C:\Program Files\Altiris"
    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(strFolderName) Then fso.DeleteFolder strFolderName


    A humble batch file would be an easier solution to someone with limited programming skills, provided that aexnsagent.exe is active during the whole uninstall process:

    @echo off
    "C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe" /uninstall /qn
    :Loop
    tasklist | find /i "aexnsagent.exe" || goto :DeleteFolder
    timeout 5 > nul
    goto Loop
    :DeleteFolder
    rd /s /q "C:\Program Files\Altiris"

    Note also that removing a folder from "Program Files" requires elevation under Vista and higher.

    Friday, February 27, 2015 2:27 PM
  • It won't work with a batch file either if it is the same Altiris installer that we have known for years.

    ¯\_(ツ)_/¯

    Friday, February 27, 2015 3:26 PM
  • Hi Frederik,

    thanks for your reply, requirement is to create script using only vbscript.


    prakash

    Friday, February 27, 2015 3:33 PM
  • Hi Senne,

    i'm getting "permission denied" error when i merge into single script, it runs perfectly when i run separately.


    prakash

    Friday, February 27, 2015 3:34 PM
  • Hi Senne,

    i'm getting "permission denied" error when i merge into single script, it runs perfectly when i run separately.


    prakash

    That is what I have been trying to point out.  You cannot detect the installer.  THe EXE you call is a bootstrap that starts the installer.  Once started it quits and leaves the installer running. 

    It is possible to skip the exe and use the MSI component to open the MSI file.  The installer can then be queried for completion status of all subcomponents.  This is the only way I know of that is reliable.  You can also time the uninstall and place a wait.  Run in a loop and, as long as the folder cannot be deleted assume that you have to wait longer.  Keep looping until the folder can be deleted.


    ¯\_(ツ)_/¯

    Friday, February 27, 2015 3:40 PM
  • This is not a Symantec Management (Altiris) support forum.

    For instructions on creating policies to uninstall the agent (or appropriate manual uninstall instructions), you need to find a more appropriate forum, which you should be able to find by searching.


    -- Bill Stewart [Bill_Stewart]


    • Edited by Bill_Stewart Friday, February 27, 2015 4:02 PM
    • Proposed as answer by Bill_Stewart Tuesday, March 3, 2015 3:10 PM
    • Marked as answer by Bill_Stewart Monday, April 6, 2015 9:48 PM
    Friday, February 27, 2015 4:02 PM
  • Hi Senne,

    The following script worked for me... thanks all for your reply.....

    Set objShell = WScript.CreateObject("WSCript.shell")
    objShell.run """C:\Program Files\Altiris\Altiris Agent\aexnsagent.exe"" /uninstall /qn"


    WScript.Sleep 1000 * 60 * 1

    strFolderName = "C:\Program Files\Altiris"
     Set fso = CreateObject("Scripting.FileSystemObject")
     If fso.FolderExists(strFolderName) Then
     fso.DeleteFolder strFolderName
    End If



    prakash

    Monday, March 2, 2015 11:39 AM
  • This is not recommended, because the uninstall may not be finished by the time the wait completes.

    As noted, this is not a Symantec Management (Altiris) forum. This is a general Windows scripting forum.

    For correct instructions on how to uninstall the Symantec Management (Altiris) Agent, you need to ask in a more appropriate forum.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 2, 2015 1:38 PM