Solved

strange vbs error in system startup script

Posted on 2006-07-11
3
342 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

749 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