Announcement

Collapse
No announcement yet.

VBS Scripting Woes

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBS Scripting Woes

    Hey all,

    Before I begin, I based the majority of this script off of the one found at http://forums.petri.com/showthread.php?t=17592.

    I want to make two scripts, one ran as an incidental script that installs the version of Spybot found on the server and one ran weekly as a script that tells Spybot to run, update itself, run a sweep, then close. The problem is when I run either of my scripts they peg the processor out at 100%. I would like to schedule these scripts on the domain controller to be ran as the domain admin.

    The install script is the following. Any ideas as to why it doesn't install the software and also pegs the DC out? The scan script is very similiar, and only the last bit is changed for obvious reasons.

    Code:
    On Error Resume Next
    
    strContainer = "ou=MyBusiness,ou=Computers,ou=SBSComputers" 
    
    Set objRootDSE = GetObject("LDAP://rootDSE")
    
    If strContainer = "" Then
        strADsPath = objRootDSE.Get("defaultNamingContext")
    Else
        strADsPath = strContainer & "," & objRootDSE.Get("defaultNamingContext")
    End If
    
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"
    
    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection
    
    objCommand.CommandText = "<LDAP://" & strADsPath & ">;" & "(objectCategory=computer)" & ";name"
     
    Set objRecordSet = objCommand.Execute
    
    While Not objRecordSet.EOF
    
        SpybotInstall objRecordSet.Fields("Name")
        objRecordSet.MoveNext
    
    Wend
    
    objConnection.Close
    
    
    
    Sub SpybotInstall(strComputer)
    
        set objShell = CreateObject("WScript.Shell")
        objShell.Run "G:\IT\spybot\spybotsd152.exe /verysilent /log=G:\IT\spybot\install_logs\Spybot_Install_Log-" & strComputer & ".txt /norestart /noicons /components=main"
    
    End Sub

  • #2
    Re: VBS Scripting Woes

    Originally posted by OUberLord View Post
    Hey all,

    Code:
        set objShell = CreateObject("WScript.Shell")
        objShell.Run "G:\IT\spybot\spybotsd152.exe /verysilent /log=G:\IT\spybot\install_logs\Spybot_Install_Log-" & 
    strComputer & ".txt /norestart /noicons /components=main"
    
    End Sub
    You could try changing to the UNC path instead of G:\ and see if that does the trick.
    Caesar's cipher - 3

    ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

    SFX JNRS FC U6 MNGR

    Comment


    • #3
      Re: VBS Scripting Woes

      Curious as to why you are install Spybot on a DC.
      1 1 was a racehorse.
      2 2 was 1 2.
      1 1 1 1 race 1 day,
      2 2 1 1 2

      Comment


      • #4
        Re: VBS Scripting Woes

        You might want to ask if this can be moved to the "Scripting" forum, too - you might get a stronger response...


        Tom
        For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

        Anything you say will be misquoted and used against you

        Comment


        • #5
          Re: VBS Scripting Woes

          I don't actually want to install it on the DC, but on just the PCs in one OU in AD. I just want to run it from the DC for convenience.

          Comment


          • #6
            Re: VBS Scripting Woes

            <Moved to Scripting>
            Server 2000 MCP
            Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

            ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

            Comment


            • #7
              Re: VBS Scripting Woes

              Originally posted by OUberLord View Post
              I don't actually want to install it on the DC, but on just the PCs in one OU in AD. I just want to run it from the DC for convenience.
              biggles77 is right, if you run your script on the server it'll try to install the program only on that server. Although the script does query the OU and retrieve computer accountnames it only uses the computernames just for naming the logfile, not for connecting.

              And L4ndy has a good point too, when you want to execute processes on remote systems, use a path to the file that is valid on the remote computer.


              For executing a program on a remote computer you can use PsExec.exe http://technet.microsoft.com/en-us/s.../bb897553.aspx

              sample:
              Code:
              @echo off
              Set "SharedFolder=\\server\share\IT\spybot"
              If Not exist "%SharedFolder%\install_logs" MkDir "%SharedFolder%\install_logs"
              
              (Set CommandLine="%SharedFolder%\spybotsd152.exe" /verysilent /log="%SharedFolder%\install_logs\Spybot_Install_Log-%1.txt" /norestart /noicons /components=main)
              Start ""/min "psexec.exe" \\%1 -c -d %CommandLine%

              A completed batchscript could run a PsExec command-line for each computer:
              - the batch use dsquery.exe, to find computers in the OU, and retrieve the accountname.
              - it pings the computer to check if it is powered on.
              - then it will run PsExec.exe to connect and starting the installation process on the remote computer.

              \Rems

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: VBS Scripting Woes

                Code:
                ::  batch_script  
                :: Author: Remco Simons, NL 2008
                :: Source: http://forums.petri.com/showthread.php?t=25358
                
                @echo off
                SETLOCAL ENABLEDELAYEDEXPANSION
                
                :: Variables
                Set "SharedFolder=\\server\share\IT\spybot"
                If Not exist "%SharedFolder%\install_logs" MkDir "%SharedFolder%\install_logs"
                
                :: Enumerate the computerobjects in one OU
                (Set startnode="ou=MyBusiness,ou=Computers,ou=SBSComputers,dc=domain,dc=local")
                
                :: Create a list of Computernames that were NOT connectable.
                Set "Output2=%~dp0skipped.txt"
                If exist "%Output2%" Del "%Output2%"
                
                ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
                
                set "_Title= Querying Active Directory . . . "
                
                Set "iCnt=0"
                
                cls & Color 6B
                
                FOR /F %%* IN (
                   'DSQUERY.exe COMPUTER %startnode% -scope onelevel -O sAmid'
                   ) DO (
                      SET "SAMID=%%*" & (SET SAMID=!SAMID:~1,-2!)
                      Set /a iCnt=!iCnt!+1 & Title %_Title% [!iCnt!]
                      Ping.exe -n 2 -w 350 !SAMID! | Find/i "TTL=" >Nul &&( 
                                  set "_R="  & call:SubRoutine1 !SAMID!)||(
                                  Set "_R=X" & call:SubRoutine2 !SAMID!)
                      @echo.!_R! 	!SAMID!
                )
                
                ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
                
                Title done.
                
                Set "skipped=0" * Counting the skipped computers;
                
                FOR /F "usebackq" %%* IN ("%Output2%") do (
                    Set /a skipped=!skipped!+1
                )
                Set /a successes=%iCnt%-%skipped%
                
                cls & COLOR fc
                
                echo.&echo.%date% - %time%
                echo.---------------------------------------------
                echo.&echo.  Found %iCnt% computerobjects in
                      echo.  %startnode%
                echo.&echo.  %successes% computers were pingable
                      echo.  %skipped% computers were NOT pingable
                echo.&echo.  The skipped computers are listed in:
                      echo.  %Output2%
                echo.
                
                ENDLOCAL
                
                pause >nul
                :: finished!
                
                
                GoTo:EOF -------------
                 :SubRoutine1
                 (Set CommandLine="%SharedFolder%\spybotsd152.exe" /verysilent /log="%SharedFolder%\install_logs\Spybot_Install_Log-%1.txt" /norestart /noicons /components=main)
                 Start ""/min "psexec.exe" \\%1 -c -d %CommandLine%
                GoTo:EOF -------------
                
                GoTo:EOF -------------
                 :SubRoutine2
                 >>"%Output2%" echo.!SAMID!
                GoTo:EOF -------------
                \Rems
                Last edited by Rems; 14th July 2008, 19:21. Reason: corrected "startnode" (OU dn)

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment

                Working...
                X