mercenary
mercenary

Reputation: 69

Executing a program using "Runas"

I'm running a runas with commands/arguments using .bat and .vbs to bypass an SRP restriction(for educational only), the .vbs file is to hide the command window, how do I write this on VB.Net or C#. I want to make it a standalone .exe file because I want to disallowed also the Command Prompt and VBScript also in the machine using SRP.

HideBat.vbs

    CreateObject("Wscript.Shell").Run "run.bat", 0, True

run.bat

    @ ECHO OFF
    runas /trustlevel:"Unrestricted" "C:\Program Files\Deluge\deluged.exe"

This is what I come up so far.

     Dim myprocess As New System.Diagnostics.Process()
     myprocess.StartInfo.FileName = Path.Combine(GetFolderPath(SpecialFolder.System), "runas.exe")
     myprocess.StartInfo.Arguments = "/trustlevel:"Unrestricted"" & " " & "c:\program.exe"
     myprocess.Start()

There is a problem on the Unrestricted, because of quotes.

Upvotes: 0

Views: 716

Answers (1)

mason
mason

Reputation: 32693

Assuming C# (I don't know why you tagged this as VB.NET and C#)

Process myprocess = new Process();
myprocess.StartInfo.FileName = Path.Combine(GetFolderPath(SpecialFolder.System), "runas.exe");
myprocess.StartInfo.Arguments = "/trustlevel:\\\"Unrestricted\" \"C:\\Program Files\\Deluge\\deluged.exe\"";
myprocess.Start();

Use backslash to escape double quotes inside a string.

Updated answer-forgot to backslash the backslashes in the path.

Upvotes: 1

Related Questions