1
Answer

Shell program not executing via web when using server name

Scott Pate

Scott Pate

9y
428
1
 

I have a VB.Net 2012 web application where we are trying to execute a process which starts a vbs script located on a Remote VM.

The code works properly when I run it directly within the Visual Studio debugger, which spawns via the following URL:

http://localhost:63579/DDFE/MultiRun.aspx?&Sort=

However when we publish the application to the production folder and run the web app the cmd process does not seem to be executed properly. Below is the published URL:

http://ne1dwgtqa301/DDFE/MultiRun.aspx?&Sort=

You can see that the difference is in the machine name of "ne1dwgtqa301" vs "localhost:63579".

I assume this is a permissions issue but have been unable to determine the root cause of the Shell command not executing properly when run via the published URL. This does not run even when executed on the host server, but the command works properly when run manually or via "localhost:63579" on the same server.

Any help is much appreciated!

 
Protected Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click
Dim shellCommand As String
 
For Each item As ListItem In lstVMs.Items
      If item.Selected = True Then
          shellCommand = "C:\websites\prod\DDFE\Log\psexec.exe \\NE1-VDI-" & item.Text & ".us.ad.xxx.com -e -h -u W2KXXX\user -p pswd C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe /c C:\windows\SysWoW64\cscript.exe C:\Scripts\Driver.vbs"
        Shell(shellCommand, AppWinStyle.Hide)
    End If
Next
 
End Sub 'btnRun_Click 
 
Answers (1)