Hack Forums
[.NET] Need help running a silent CMD command (Shell is not working) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Need help running a silent CMD command (Shell is not working) (/showthread.php?tid=4650900)



Need help running a silent CMD command (Shell is not working) - Mr Fox - Jan 23, 2015

Alright I need when a button is pressed it runs the commands "start <application.exe> <IP> <Port>"

However I want it to run silently. When I try opening CMD and inputting the command, it goes through however it opens the window (I tried using taskkill afterwards but I would highly prefer it being 100% silent).

When I try using Shell it make the defualt directory system32 so when it runs the "start <Application.exe> <IP> <Port>" it cannot find the specified application.

Is there anyway to get shell to read from the current directory?


* - Zyklon A - Jan 23, 2015

PHP Code

<?php 
Dim processStartInfo 
As ProcessStartInfo = New ProcessStartInfo()
processStartInfo.FileName = "app.exe"
processStartInfo.Arguments = "/k <IP> <Port>"
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden
processStartInfo
.UseShellExecute = True
Process
.Start(processStartInfo) 

This should work!


* - Mr Fox - Jan 23, 2015

(Jan 23, 2015 12:04 PM)Deodorant Wrote:  
PHP Code

<?php 
Dim processStartInfo 
As ProcessStartInfo = New ProcessStartInfo()
processStartInfo.FileName = "app.exe"
processStartInfo.Arguments = "/k <IP> <Port>"
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden
processStartInfo
.UseShellExecute = True
Process
.Start(processStartInfo) 

This should work!

The application needs to be run with the Args. Or I'll get an error since once the application initializes it ignores the cmd args


* - Odus - Jan 23, 2015

Like this?

[Image: k1uvf6T.gif]

Code:
Code
Dim p As New ProcessStartInfo("C:\Users\Odus\Desktop\VBConsole.exe", "hello") 'With {.WindowStyle = ProcessWindowStyle.Hidden, .CreateNoWindow = True}
Process.Start(p)



* - Mr Fox - Jan 23, 2015

(Jan 23, 2015 01:43 PM)Odus Wrote:  Like this?

[Image: k1uvf6T.gif]

Code:
Code
Dim p As New ProcessStartInfo("C:\Users\Odus\Desktop\VBConsole.exe", "hello") 'With {.WindowStyle = ProcessWindowStyle.Hidden, .CreateNoWindow = True}
Process.Start(p)

instead of
Code
C:\Users\Odus\Desktop\VBConsole.exe

I need to have it in the files location


* - Odus - Jan 23, 2015

(Jan 23, 2015 02:02 PM)etc. Wrote:  instead of
Code
C:\Users\Odus\Desktop\VBConsole.exe

I need to have it in the files location

Replace with:
Code
AppDomain.CurrentDomain.BaseDirectory & "whatever.exe"