Link to home
Start Free TrialLog in
Avatar of TREER
TREER

asked on

run script from vb.net

I Have a vb.net prog which contains a flie "vbscript1.vbs" simply i need to click a button and for the script to run
Avatar of sirbounty
sirbounty
Flag of United States of America image

Try:

System.Diagnostics.Process.Start ("c:\PathtoScript\vbscript1.vbs")
Dim obj as new Process
obj.start("\\server\share\folder\vbscript1.vbs")


You can use obj.WaitForExit() method to wait till the process has
termintated.
Avatar of TREER
TREER

ASKER

unfortunately, your ideas do not work although they nearly do
the following error occurs when i attempt your code

line
char 1
error Object expected
code 800A138F
Source Microsoft jscript runtime error

so i replaced my javascript code  with a simple
 alert("try")

but still the same error occurs

 i have increased the points to 500, many thanks for your time


This indicates that it 'is' working - but reporting back an error in the called script..
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

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
Avatar of TREER

ASKER

sirbounty ,

i can see your logic, and indeed that was my first thought, that is why i replaced my original script with just the one line


alert("try")

the result was the same error



graye, the script is javascript, will this be the same?
I don't know much about javascript, but that's a vb script you're trying to run and alert("try") is not a valid command...
try

wscript.echo "Hello"

instead...
You can run VB.Net Shell() function to execute the script as simple as possible:
http://www.dotnet247.com/247reference/msgs/57/289295.aspx