Executing a .vbs file rom within another .vbs file - Run Vs. Exec
Posted on 2003-03-04
Okaaay. I'm a crappy admin and can't be bothered to keep changing the various settings on each workstartion when a user screws them up.
I've wrote a little 2 part .vbs file to do this, and it's got a small routine to stop the bastards deleting it.
The original file (parent.vbs) moves itself into c:\windows\system and executes. It WriteLines a new .vbs file which runs on startup. That file contains something like the code below:
Set wsh = wscript.createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set vbsExec = wsh.run("blah.vbs") '<-- PROBLEM!
Set vbsExec = Nothing
Set fso = Nothing
Set wsh = Nothing
My problem (marked above) as far as i can tell is with the wsh.Exec vs Wsh.Run - .Run works but throws up an ugly error whilst .Exec just seems to hang. wtf?
Is the script triping over itself because it doesen't execute quick enough? have i just messed up big time?
This is definately worth more than 40 points, but i don't have any more. A good answer will get some sweets sent to the poster or 'something'. perhaps.