none
VB.Net 2k12 Shell do not execute the files RRS feed

  • Question

  • Hi! I created an website project, to integrate an automatization to the process of compiling for developers at my job. At first I thought that it wasn't working right because the lack of administrator privilegeds but I just try to run a simple batch file and i've come realized that didn't do it.

    I've try so far this two options:

    Dim copiaShell As Process
    Dim parametroParaShell As String
    parametroParaShell = ALotOfArguments
    
    copiaShell.StartInfo.UseShellExecute = False
    copiaShell.StartInfo.FileName = "D:\Folder\FILE.bat"
    copiaShell.StartInfo.CreateNoWindow = True
    copiaShell.StartInfo.Arguments = parametroParaShell 
    copiaShell.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    copiaShell.Start()
    copiaShell.WaitForExit()

    And this one:

    Dim batt = "D:\Compiladores\vb-RealizaCopia.bat"
    parametroParaShell = ALotOfParameters
    rta1 = Shell(batt & " " & parametroParaShell, AppWinStyle.Hide, True)

    With the debug works perfectly, once i've publish stops working.

    Thank you for your time.

    Greetings from Argentina.



    • Edited by Agustin Lare Wednesday, September 20, 2017 6:12 PM
    Wednesday, September 20, 2017 2:39 PM

Answers

All replies

  • Did you say you were running this from a web application? If so then I would post to the ASP.NET forum below because of the security involved.

    https://forums.asp.net/25.aspx/1?Security


    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Agustin Lare Friday, October 13, 2017 9:11 PM
    Wednesday, September 20, 2017 4:03 PM
  • Paul, thank you for your recomendation. I will do it regadles the issue I have about the authentification.

    But recently i come to realize that the Shell function do not work. I'm going to edit the origial post so i can explain it better.

    Wednesday, September 20, 2017 5:56 PM
  • Keep in mind that once you publish from your machine to a web server the security requirements will change.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, September 20, 2017 6:39 PM
  • I do, thank you Paul. That's why just for testing, disable all kind of security measures, and give full control to Everyone.

    The batch that executes the shell, first of all leaves a log, and that ain't happening, plus the catch statement is not reached either.

    Wednesday, September 20, 2017 7:46 PM
  • Try...Catch will not catch any errors from a shelled process - only whether the file was found. If your shelled process is not generating a log file you may want to see if there are any related errors in the Windows Event Log.

    You may also want to set RedirectStandardOutput to True and read the results of the operation to see if any additional info is provided.


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, September 20, 2017 8:21 PM
  • Paul, thank you again for your anwser and sorry for the delay anwser.

    I did exactly that and include and stanrdardError. The standardOutPut prints what it should except for the output of the bat file. The standardError creates the file, but jsut with a space " " (no quotes). I've even make the excercise of provoke an error and print what it should so I could be sure that the code was working properly.

    I think you're right and this is a problem of permissions and security.

    Thank you so much for your time.

    Friday, October 13, 2017 9:10 PM