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("wscr ipt.shell" )
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
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.
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("wscr
Set fso = CreateObject("Scripting.Fi
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Accept sybe's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer