Re: Permission denied only when 2 computers are used

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"savvy95" <savvy95@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EC5A9D8D-6F1F-4132-BC27-B1276098A508@xxxxxxxxxxxxxxxx
> When I run this script using 1 remote computer name, it works. When I add
> another computername, I get "Permission Denied". Can anyone help me?
> ================
>
> Option Explicit
> Dim strComputer, oFile, oFS, arrComputers, objWMIService, colItems,
objItem
> Dim username, password
> Const wbemFlagReturnImmediately = &h10, wbemFlagForwardOnly = &h20
> Const ForReading=1, ForWriting=2, ForAppending=8
>
>
> Set oFS = CreateObject("Scripting.FileSystemObject")
> 'Set strFile = "c:\Scripts\ComputerApps.txt"
>
> 'if I take away one computername the script runs fine
> arrComputers = Array("nea010","nea014")
>
> For Each strComputer in arrComputers
>
> Set objWMIService =
> GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
> "\root\CIMV2")
> Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product",
> "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
>
> Set oFile =
> oFS.OpenTextFile("c:\Scripts\ComputerApps.txt",ForAppending,FALSE)
> 'oFile.WriteLine "Computer Name; Insert Date;SubKey;Display name;Display
> version;Install location;Install Date;Publisher"
>
> For Each objItem In colItems
> oFile.Writeline strComputer & ";" & Date & " " & Time & ";" &
> objItem.IdentifyingNumber _
> & ";" & objItem.Description & ";" & objItem.Version & ";" &
> objItem.PackageCache _
> & ";" & objItem.InstallDate & ";" & objItem.Vendor & "; WMI"
> Next
> Next
>
>
> Function WMIDateStringToDate(dtmDate)
> WScript.Echo dtm:
> WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
> Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
> & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" &
> Mid(dtmDate,13, 2))
> End Function

It looks to me like your problem is that you are opening a text file for
appending inside of your loop but not closing it. It would probably be best
to move your 'Set oFile...' line above your 'For Each strComputer in
arrComputers' line & then put an 'oFile.Close' line just below the 'Next'
line for your main loop.


.



Relevant Pages

  • Re: Disable multiple computers logon
    ... > script appended username, computername, date/time, and IP address to a text ... a malicious user could modify the logs. ... > script removes the line added by the logon script, so it must search for the ...
    (microsoft.public.windows.server.scripting)
  • Re: WebBrowser Control (VB5, VB6) & window.external. Possible?
    ... There isn't anything specific I want to retrieve. ... Suppose this page needs to display the client's computername, do some calculations with the free diskspace and use some data from a device attached to the client's computer. ... So I want the page to be able to "ask" the hosting VB app for this information. ... <SCRIPT Language=JavaScript> ...
    (microsoft.public.vb.general.discussion)
  • RE: Get Computername for a Specific User
    ... appear possible on a Microsoft AD Network via MMC, command line methods, nor ... line method into a batchfile script; a Visual Basic script or PowerShell ... copying a single file to the computers and then executing it remotely is ... I want the resulting User's Computername to be written to a simple ...
    (microsoft.public.windowsxp.security_admin)
  • Re: scripting newb
    ... I was able to hobble this together from another script posted by Dan ... Dim strSearch, strAdsPath, strServerName 'from search script ...     'Prompt for search criteria ... computerName, samAccountName, givenName, sn, AdsPath ...
    (microsoft.public.scripting.vbscript)
  • Re: map drive based on computer name
    ... computername but hava had little success. ... for the second location, the first 5 letters are 61new. ... the script is ... which is passed as a string. ...
    (microsoft.public.scripting.vbscript)