Solved

strange vbs error in system startup script

Posted on 2006-07-11
3
337 Views
Last Modified: 2013-11-14
I am using the following script on system startup. If the system is configured to log right in as admin, I see now error message. If it is configured with a login prompt, I get the following error message:

Windows script host error:

0

Then there is an ok button.


Here is my vbs file:

strComputer = "ed-f6b331079aa6" ' " use "." for local computer

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

Set objSoftware = objWMIService.Get("Win32_Product")

errReturn = objSoftware.Install("C:\SOFTWARE.msi",,True)

WScript.Echo errReturn
0
Comment
Question by:rilliam
  • 2
3 Comments
 
LVL 8

Expert Comment

by:Shakti109
ID: 17087369

The problem is the "impersonation" and also the "timing" of the script.

If the script is being run as part of group policy, and has been configured as a "machine" script as opposed to a "user" script, then it will try to run when the system starts up. Since there is no user context, it cant impersonate anything to run the .MSI based installation.  It gets to the log-in screen and goes "oops, no user, im done".

There is another problem, and that of user rights.

If your environment is set up securely, and such that "normal" users do not have rights to install (or delete/etc) software, then if that script runs in any context OTHER than the admin (local, or domain) it will fail due to lack of permissions.

Are you trying to run this script from the registry via the "run" key? or is this being applied via group policy?
0
 

Author Comment

by:rilliam
ID: 17094162
It is local policy through run key. We cannot use active directory in this scenario.

My understanding was that whatever is run as a startup script is run as admin, is that correct?

The msi does install successfully.

I am not a programmer, so I was hoping that maybe someone could at the very least confirm what "0" means as an error message. And maybe also at least confirm that it can be removed with maybe error handling.

This work is an example for our programmers to work from and I would like this loose end to be explained to them when I hand it over.
0
 
LVL 8

Accepted Solution

by:
Shakti109 earned 250 total points
ID: 17095729

If something is placed in the "run" key of the registry, it runs under the context of whoever is logged-on at the time.

There are a few possibilities with this return of 0.

Zero usually (-usually-), means "no error condition", anything other than 0 signifies some kind of exception.

If the .msi is installing correctly, then what is likely happening is the following :

When the script gets to : WScript.Echo errReturn

The error is 0, meaning all is ok and it "echo's" it to it's own popup box. You can test this by commenting out that line.

Now that you have added that the .MSI installs correctly, I am fairly confident that it is simply passing back that "everything is just fine, i'm done" in that pop-up box.  

To "trap" the error they could do something like :

if errReturn <> 0 then
   WScript.Echo "Error installing application : " & errReturn
end if

This would only show that pop-up box if it really does have a problem.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now