Solved

strange vbs error in system startup script

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

867 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

21 Experts available now in Live!

Get 1:1 Help Now