Running a program from a windows share

Hi,

I have am creating a windows service app that every so often needs to run another program.

The program it requires to run is held on a share on another server. e.g \\other_server\path_to_file\other.exe

I’ve tried to use the shell class but nothing runs and i’m getting an error code of zero and nothing in result.

If I run the same command from a windows shell everything works as expected.

Can anyone offer any help?

Heres what I have.

Dim sh As New Shell
sh.Mode = 1
sh.Arguments = "http://www.google.co.uk"
sh.Execute("\\\\OTHER_SERVER\\path_to_file\\other.exe")

System.DebugLog "Shell Command Error:" +  str(sh.ErrorCode)
System.DebugLog "Shell Command Result:" +  sh.result

Regards

Andy

You’ll need to mount the external server’s volume for this to work. It works in cmd and PowerShell because they understand the “\\server” syntax and do the mount for you.

To see what I mean, after you call that in cmd, check your volumes in Explorer.

If it is really running as a service, you must assign the service an user account to run. The standard “local system”-account most services run under does not have access to network-shares. The user the service is assigned to must have rights to access your UNC-path.

Thanks Tim.

Thats not going to be possible in the environment the program will be running in. I might have to have a re-think.

I have just noticed after reading the help more thoroughly that I need a loop to check if the shell is still running. I was checking for the error before the shell had finished.

So this now at least gives me an error.

Dim sh As New Shell
sh.Mode = 1
sh.Arguments = "http://www.google.co.uk"
sh.Execute("\\\\OTHER_SERVER\\path_to_file\\other.exe")

do
    
    App.doevents(50)
    
loop until sh.isrunning = false or App.StopProcessing = true

System.DebugLog "Shell Command Error:" +  str(sh.ErrorCode)
System.DebugLog "Shell Command Result:" +  sh.result

Marcus: I should be ok with this particular share as its accessible by everyone.

Why not use the LAUNCH option of FOLDERITEM?

[quote=159125:@Andy Marshman]I have just noticed after reading the help more thoroughly that I need a loop to check if the shell is still running. I was checking for the error before the shell had finished.

[/quote]
Also, be sure to set the sh.Timeout to -1.