none
How to create VBS script for multiple user (run at same time RRS feed

  • Question

  • Hi I have created a VBS script to install multiple windows patch, but i am facing one problem that if one user run the script other user cannot launch that script because its give access denied error and once patch installation finish in one user than another user can use it.

    So can anyone help me how to modify it so that everyone can run it individually at same time.

    please find the script

    Dim fso, logFile, scriptDir
    scriptDir = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set logFile = fso.OpenTextFile(scriptDir & "MicrosoftUpdatesInstall.log", 8, True)
    logFile.WriteLine "==============================================================================="
    logFile.WriteLine Now()
    '=======================================================================
    ' Please place the updates in a folder and modify the below folder path
    spPatchFolder = "\\hridnp1\common$\All Staff\General Info\Outlook Patch"
    '=======================================================================
    InstallPatches(spPatchFolder)
    logFile.WriteLine "==============================================================================="
    MsgBox "Microsoft updates installation completed successfully!",64, "Microsoft updates"

    Set fso = Nothing
    Set logFile = Nothing
    WScript.Quit

    Function InstallPatches(sFolder)
        Set objfso = CreateObject("Scripting.FileSystemObject")
        Set objShell = CreateObject("Wscript.Shell")
        Set folder = objfso.GetFolder(sFolder)
        Set files = folder.Files
        For each sFile In files
            If Ucase(Right(sFile.name,3)) = "EXE" Then
                'cmd.exe /c <file name>.exe /quiet /norestart
                i=objShell.Run ("Cmd.exe /c" & Chr(34) & sfolder &"\"&sFile.name &chr(34) &" /quiet /norestart", 1, True)
                If i = 0 Or i = 3010 Then
                    logFile.WriteLine chr(34) & folder & "\" & sFile.name & chr(34) & " installation completed Successfully"
                Else
                    logFile.WriteLine chr(34) & folder & "\" & sFile.name & chr(34) & " installation failed. Exit Code: " & i
                End If
            
            End If
        Next
        For Each Subfolder in folder.SubFolders
            InstallPatches(Subfolder)
        Next
        Set objfso = Nothing
        Set objShell = Nothing
        Set folder = Nothing
        Set files = Nothing
    End Function


    Rakesh Kumar

    • Moved by Bill_Stewart Monday, April 30, 2018 9:17 PM This is not "scripts on demand"
    Tuesday, February 20, 2018 11:49 AM

All replies

  • You have to use separate log files for each user.


    \_(ツ)_/

    Tuesday, February 20, 2018 12:23 PM
  • Hi,

    Can you suggest how to add separate log file for each user PC NAME ? to check whether its installed or not.

    Thanks

    Rakesh


    Rakesh Kumar

    Wednesday, February 21, 2018 5:28 AM