?
Solved

strange vbs error in system startup script

Posted on 2006-07-11
3
Medium Priority
?
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 750 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
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 …
Six Sigma Control Plans
Suggested Courses

741 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