Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Environment Scripting Error

Reply
 
Old 04-08-2009   #1 (permalink)
Taztug


 
 

Environment Scripting Error

i have created a script to remove a set of applications from workstations. I
am testing this script on XP SP2, Vista Ultimate and Vista Business. On the
XP machines and the Vista Ultimate the script works fine. on the vista
Business machine I get the following error:

Microsoft VBScript runtime error: File name or class name not found during
Automation operation: 'Environment'

This is the snippet of code causing the problem:
'Create the working shell
Set WshShell = WScript.CreateObject("WScript.Shell")

Set wshenvironment = WshShell.Environment("Process")

C_Name = wshenvironment("COMPUTERNAME")

The intent is to create and output file that has the computer name as the
file name and lists the application removed. Once I get past this on the
Vista Business machine I can work the rest of it.

Any ideas on what might be missing? I thought it might be the visual
scripting but can't find one to install on vista.

My System SpecsSystem Spec
Old 04-08-2009   #2 (permalink)
Jon Wallace


 
 

Re: Environment Scripting Error


To me this doesn't make sense and seems like you have a problem with your
base VBScript environment. I don't have a Vista Business build at hand,
just Enterprise and the code you posted works fine - I don't expect it to be
different on Vista Business.

You could try maybe downloading and installing the Windows Scripting Host
package like this -
http://www.microsoft.com/downloads/d...displaylang=en
and hopefully it will repair anything that's wrong.

I could be totally off here mind, but again i'm pretty sure Business doesn't
have a different implementation of VBScript than any other...

Hope this helps,
Jon

www.insidetheregistry.com

---

"Taztug" <Taztug@xxxxxx> wrote in message
news:5C9295B9-4DDA-4A5F-91B6-4D4F27A9E9EB@xxxxxx
Quote:

>i have created a script to remove a set of applications from workstations.
>I
> am testing this script on XP SP2, Vista Ultimate and Vista Business. On
> the
> XP machines and the Vista Ultimate the script works fine. on the vista
> Business machine I get the following error:
>
> Microsoft VBScript runtime error: File name or class name not found during
> Automation operation: 'Environment'
>
> This is the snippet of code causing the problem:
> 'Create the working shell
> Set WshShell = WScript.CreateObject("WScript.Shell")
>
> Set wshenvironment = WshShell.Environment("Process")
>
> C_Name = wshenvironment("COMPUTERNAME")
>
> The intent is to create and output file that has the computer name as the
> file name and lists the application removed. Once I get past this on the
> Vista Business machine I can work the rest of it.
>
> Any ideas on what might be missing? I thought it might be the visual
> scripting but can't find one to install on vista.
My System SpecsSystem Spec
Old 04-08-2009   #3 (permalink)
Pegasus [MVP]


 
 

Re: Environment Scripting Error


"Taztug" <Taztug@xxxxxx> wrote in message
news:5C9295B9-4DDA-4A5F-91B6-4D4F27A9E9EB@xxxxxx
Quote:

>i have created a script to remove a set of applications from workstations.
>I
> am testing this script on XP SP2, Vista Ultimate and Vista Business. On
> the
> XP machines and the Vista Ultimate the script works fine. on the vista
> Business machine I get the following error:
>
> Microsoft VBScript runtime error: File name or class name not found during
> Automation operation: 'Environment'
>
> This is the snippet of code causing the problem:
> 'Create the working shell
> Set WshShell = WScript.CreateObject("WScript.Shell")
>
> Set wshenvironment = WshShell.Environment("Process")
>
> C_Name = wshenvironment("COMPUTERNAME")
>
> The intent is to create and output file that has the computer name as the
> file name and lists the application removed. Once I get past this on the
> Vista Business machine I can work the rest of it.
>
> Any ideas on what might be missing? I thought it might be the visual
> scripting but can't find one to install on vista.
Have you tried an alternative approach, e.g.
C_Name = WshShell.ExpandEnvironmentStrings("%ComputerName%")


My System SpecsSystem Spec
Old 04-08-2009   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: Environment Scripting Error


"Taztug" <Taztug@xxxxxx> wrote in message
news:5C9295B9-4DDA-4A5F-91B6-4D4F27A9E9EB@xxxxxx
Quote:

>i have created a script to remove a set of applications from workstations.
>I
> am testing this script on XP SP2, Vista Ultimate and Vista Business. On
> the
> XP machines and the Vista Ultimate the script works fine. on the vista
> Business machine I get the following error:
>
> Microsoft VBScript runtime error: File name or class name not found during
> Automation operation: 'Environment'
>
> This is the snippet of code causing the problem:
> 'Create the working shell
> Set WshShell = WScript.CreateObject("WScript.Shell")
>
> Set wshenvironment = WshShell.Environment("Process")
>
> C_Name = wshenvironment("COMPUTERNAME")
>
> The intent is to create and output file that has the computer name as the
> file name and lists the application removed. Once I get past this on the
> Vista Business machine I can work the rest of it.
>
> Any ideas on what might be missing? I thought it might be the visual
> scripting but can't find one to install on vista.
Your snippet works fine on my laptop with Windows Vista Business. Can you
confirm that the environment variable has the expected value?

An alternative way to retrieve the NetBIOS name of the current computer is:

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 04-13-2009   #5 (permalink)
Taztug


 
 

Re: Environment Scripting Error

Thanks to all who responded. The different options to get the computer name
will come in handy at other times. Unfortunately, as I suspected and as was
posted by Jon the WSH files were not installed. Once installed the script
ran fine.

"Jon Wallace" wrote:
Quote:

>
> To me this doesn't make sense and seems like you have a problem with your
> base VBScript environment. I don't have a Vista Business build at hand,
> just Enterprise and the code you posted works fine - I don't expect it to be
> different on Vista Business.
>
> You could try maybe downloading and installing the Windows Scripting Host
> package like this -
> http://www.microsoft.com/downloads/d...displaylang=en
> and hopefully it will repair anything that's wrong.
>
> I could be totally off here mind, but again i'm pretty sure Business doesn't
> have a different implementation of VBScript than any other...
>
> Hope this helps,
> Jon
>
> www.insidetheregistry.com
>
> ---
>
> "Taztug" <Taztug@xxxxxx> wrote in message
> news:5C9295B9-4DDA-4A5F-91B6-4D4F27A9E9EB@xxxxxx
Quote:

> >i have created a script to remove a set of applications from workstations.
> >I
> > am testing this script on XP SP2, Vista Ultimate and Vista Business. On
> > the
> > XP machines and the Vista Ultimate the script works fine. on the vista
> > Business machine I get the following error:
> >
> > Microsoft VBScript runtime error: File name or class name not found during
> > Automation operation: 'Environment'
> >
> > This is the snippet of code causing the problem:
> > 'Create the working shell
> > Set WshShell = WScript.CreateObject("WScript.Shell")
> >
> > Set wshenvironment = WshShell.Environment("Process")
> >
> > C_Name = wshenvironment("COMPUTERNAME")
> >
> > The intent is to create and output file that has the computer name as the
> > file name and lists the application removed. Once I get past this on the
> > Vista Business machine I can work the rest of it.
> >
> > Any ideas on what might be missing? I thought it might be the visual
> > scripting but can't find one to install on vista.
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
VB scripting help VB Script
UAC and scripting Vista General
WAIK 1.1 Scripting Error Vista installation & setup
Scripting Explorer FTP PowerShell
Scripting bug? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46