1

There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor

Hey I wrote this script delete shares of a computer but when I run my script it repeats the same wscript.echo statating the share being deleted. Why does my code never end when run How do I fix that.

My fumction:

'The function that is called to run the command Line that deletes a specific share from a pc
Function DeleteThisShare(Share)
    Dim objShell
    'Logging The deleted Approved Shares
    objDeletedFile.WriteLine (Now & " - Removed share " & Trim(Share))
    DeleteThisShare = "net share " & chr(34) & Share & chr(34) &" /DELETE"
    Wscript.echo DeleteThisShare
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run DeleteThisShare
End Function

My loops:

'Compares The UnApproved Shares to the Current Shares
For Each objItem In colItems
    Dim StrNonUnapprovedShares, Item
    StrCurrentShares = objItem.name

    if instr(AdminShares,lcase(objitem.name)) > 0 or mid(objitem.name,2,1) = "$" or left(lcase(objitem.name),10) = "pkgsvrhost" then
        'Skipping known admin share
    Else
            For each Item in arrUnApprovedLines
            If Lcase(Item) = Lcase(strCurrentShares) Then
                StrNonUnapprovedShares = (StrNonUnapprovedShares & strCurrentShares & vbCrLf)
            End If
        Next
    End If
Next


Dim notUnapprovedShares, notUnapprovedLines
notUnapprovedLines = StrNonUnapprovedShares
notUnapprovedLines = Split(notUnapprovedLines, vbCrLf)

Dim y, Line2

For y = 0 to uBound(notUnapprovedLines)
    Line2 = Trim(notUnapprovedLines(y))
    If len(Line2) > 0 Then
        DeleteThisShare(Line2)
    End If
Next

2 Answers 2

1

I think the problem is caused by using the function name as a variable. That's okay with VB that you're compiling, but I don't think VBScript recognizes it in the same way. Use a separate variable name in place of DeleteThisShare, e.g. strDeleteThisShare.

Sign up to request clarification or add additional context in comments.

Comments

0

If I had to guess it's because you're creating a recursive loop by having your script echo the DeleteThisShare function. The function gets to that line and is called again before it's able to carry on.

Try to only assign values to the result of the function and use local variables to store any other debugging / temporary values.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.