Jump to content

ActiveX error when using .VBS script in WinPE


Recommended Posts

Posted

Im trying to run VBS scripts in WinPE to automate the installation of W2k and W2k3.

When i run a simple script that should start Notepad.exe, i get the following error message:

ActiveX can't create object: "wscript.shell"

Here's the script im trying to run:

----------------------------------------------------------------------------------

Dim server_shell

Dim oExec

Dim strExecPath

strExecpath= "c:\WINDOWS\system32\notepad.exe"

Set server_shell = CreateObject("wscript.shell")

Set oExec = Server_shell.exec (strExecpath)

While oExec.Status = 0

WScript.Sleep 50

Wend

wscript.echo "Done"

------------------------------------------------------------------------------------

The script runs fine on XP, and I used the BuildOptionalComponents.vbs to prepare WinPE, and ran OC.bat after booting WinPE.

What am i doing wrong?

Thanx in advance for your help and suggestions.


Posted

No, VB is not a requirement for WSH to work. If it was, WSH could not run on Windows 64-bit versions, where there is no version of non .NET VB.

I think something failed to register... Does it work if you change:

CreateObject("wscript.shell")

to

WScript.CreateObject("wscript.shell")

?

Posted

I changed the line to WScript.CreateObject("wscript.shell")

I then get the following error message:

Could not locate automation class named "wscript.shell"

Im new to WinPE, could someone tell me if its even possible in WinPE to use scripts like these?

Must be, othwerwise WinPE would be as much as useless, but im not so sure anymore.

Posted

Yes you can use vb script under pe. I have been doing it since pe 1.1

First question. did you install wsh support in your pe image? ie buildoptionalcomponents /wsh and follow the instructions on screen

Second question: did you run oc.bat before starting your script. this starts the script support

Third question: Did you strip down your pe image. This can break wshshell.

Posted

Yes, i used the buildoptionalcomponents.vbs, and in my second try, I installed all components.

I started the OC.bat by hand, and that doesnt give me an error. I did not strip it down yet, although i was planning to.

I also ran the testwsh.vbs, and that runs fine.

Posted

I got it to work guys!!

Mats question if I stripped it made me think. I began from scratch again, because I did inject lots of drivers and played with some files of my previous WinPE build.

I have now build a new one, and that one is slightly (1MB) bigger then the previous one.

Now when I run my scripts they run fine, without strange error messages.

I would like to thank all of you for your help and support!

Thumbs up guys, much appreciated! :thumbup

Posted
Guess how i found out that stripping brakes it? :)

Let me guess, you are now a retired stripper...

I still have problems running some vb scripts cos I havent msvbvm50/60.dll registered. Might get round to changing that soon.

Posted

Guess how i found out that stripping brakes it? :)

Let me guess, you are now a retired stripper...

I still have problems running some vb scripts cos I havent msvbvm50/60.dll registered. Might get round to changing that soon.

Quick fix to that is to have the dll:s and the script in the same folder. Then it should work without registration.

I still got the job but the included removelists are now known to be rather bad.

Posted

VB and WSH aren't interrelated at all - if you add the VB binaries to make WSH work, you'll be adding two unnecessary binaries. Odds are, if you are getting an error of some kind, then the COM object(s) you're interacting with are missing some dependency or registry entry.

Posted

my problem is not wsh. I have a program (not by me) that requires these to run.

PS. How do you minimise that original command window that opens up?

Posted
my problem is not wsh. I have a program (not by me) that requires these to run.

PS. How do you minimise that original command window that opens up?

Ah.

For the minimize, look in OC.bat. That's the file that launches OC2.bat, which is the one that runs minimized. Can't remember it off the top o'my head.

Posted (edited)

i know the /min switch but what it's the original cmd window, the 1st one that shows, the one where you type exit and it restarts pe.

Gonna play with some vb6 me thinks.

Found a program consolesize works great.

Edited by gadget

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...