Link to home
Start Free TrialLog in
Avatar of redshift_1
redshift_1

asked on

Executing a .vbs file rom within another .vbs file - Run Vs. Exec

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:

Function RestoreFile()
  Dim wsh,vbsExec
  Set wsh = wscript.createobject("wscript.shell")
  Set fso = CreateObject("Scripting.FileSystemObject")
    fso.MoveFile "blah.bak","blah.vbs"
      Set vbsExec = wsh.run("blah.vbs") '<-- PROBLEM!
      vbsExec.Terminate
    fso.MoveFile "blah.vbs","blah.bak"
  Set vbsExec = Nothing
  Set fso = Nothing
  Set wsh = Nothing
End Function

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.
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Moderator, my recommended disposition is:

    Accept sybe's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer