Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

strange vbs error in system startup script

Posted on 2006-07-11
3
Medium Priority
?
347 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
Six Sigma Control Plans

636 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