Re: Permission denied only when 2 computers are used
- From: "James Whitlow" <jwhitlow@xxxxxxxxxx>
- Date: Thu, 5 Jan 2006 14:14:01 -0600
"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.
.
- Follow-Ups:
- Re: Permission denied only when 2 computers are used
- From: savvy95
- Re: Permission denied only when 2 computers are used
- References:
- Permission denied only when 2 computers are used
- From: savvy95
- Permission denied only when 2 computers are used
- Prev by Date: Need some help
- Next by Date: Re: Permission denied only when 2 computers are used
- Previous by thread: Re: Permission denied only when 2 computers are used
- Next by thread: Re: Permission denied only when 2 computers are used
- Index(es):
Relevant Pages
|