Compression Script

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

I have found the following sample script on a scripting site. When I attempt
to run the script I get an error message:

Specified window "objWMIService = GetObject("winmgmts:" _" Not Present
Any susequent key sends in script may cause exceptions.

The Set colFolders = objWMIService.ExecQuery fails with a similar fault.

Anyone have any suggestions as how to fix this?

Regards



strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = 'c:\\temp'")

For Each objFolder in colFolders
errResults = objFolder.Compress
Next
 

Jon

Distinguished
Dec 4, 2003
618
0
18,980
Archived from groups: microsoft.public.windowsxp.general (More info?)

Nothing wrong with the script itself - works fine here, although that
probably doesn't help much.

Jon


"Visio Candar Control" <VisioCandarControl@discussions.microsoft.com> wrote
in message news:3925BAE7-04D4-4F00-9B63-951960163B0B@microsoft.com...
>I have found the following sample script on a scripting site. When I
>attempt
> to run the script I get an error message:
>
> Specified window "objWMIService = GetObject("winmgmts:" _" Not Present
> Any susequent key sends in script may cause exceptions.
>
> The Set colFolders = objWMIService.ExecQuery fails with a similar fault.
>
> Anyone have any suggestions as how to fix this?
>
> Regards
>
>
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colFolders = objWMIService.ExecQuery _
> ("Select * from Win32_Directory where name = 'c:\\temp'")
>
> For Each objFolder in colFolders
> errResults = objFolder.Compress
> Next
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

Just as an excercise, the _ character indicates to the scripting engine that the current line is continued on the next line of the script. This is done to allow scripts to be read more easily. Try putting the two Set statments on a single line, each.

strComputer = "."
Set objWMIService = GetObject("winmgmts: {impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery ("Select * from Win32_Directory where name = 'c:\\temp'")

For Each objFolder in colFolders
errResults = objFolder.Compress
Next

--
Doug Knox, MS-MVP Windows Media Center\Windows Powered Smart Display\Security
Win 95/98/Me/XP Tweaks and Fixes
http://www.dougknox.com
--------------------------------
Per user Group Policy Restrictions for XP Home and XP Pro
http://www.dougknox.com/xp/utils/xp_securityconsole.htm
--------------------------------
Please reply only to the newsgroup so all may benefit.
Unsolicited e-mail is not answered.

"Visio Candar Control" <VisioCandarControl@discussions.microsoft.com> wrote in message news:3925BAE7-04D4-4F00-9B63-951960163B0B@microsoft.com...
>I have found the following sample script on a scripting site. When I attempt
> to run the script I get an error message:
>
> Specified window "objWMIService = GetObject("winmgmts:" _" Not Present
> Any susequent key sends in script may cause exceptions.
>
> The Set colFolders = objWMIService.ExecQuery fails with a similar fault.
>
> Anyone have any suggestions as how to fix this?
>
> Regards
>
>
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colFolders = objWMIService.ExecQuery _
> ("Select * from Win32_Directory where name = 'c:\\temp'")
>
> For Each objFolder in colFolders
> errResults = objFolder.Compress
> Next