HelpComplex Help request

Posts 1–10 of 10 · Page 1 of 1
Complex Help request
Hello everyone i have a question everyone knows how to make an empty .exe
Code:
Dim file As System****.FileStream
        file = System****.File.Create("c:\random.exe")
But i want to know how to make that exe do like this code shell("shutdown -s") That would be very cool if someone would tell me how i will say thank you for it!!
Do you want it to be an exe file that open's, run's the code and closes automatticly ?
Yes, thats it
working on it, i will try to end it tonight
Quote Originally Posted by zarix View Post
Code:
 System****.File.AppendAllText("C:\shutdown.exe", "shutdown -s")
so i got this from nice guy but the prob is this 55621ecf006dcd23f1c83eceeb56b3e6.png
i am using VB 2010 can anyone help me out ? :|)
What you posted would only work if you wrote it with a .bat extension. .exe Tells Windows that it should be looking at the PE file format, which is very different from just a string like that. If you want to actually compile a valid executable with your code, you should read into this:
Compile code from vb.net
i can do it in .bat but i want to know how to make it .exe
Code:
 System****.File.AppendAllText("C:\text.bat", ("del C:\text"))
how to get it text.exe?
Quote Originally Posted by zarix View Post
i can do it in .bat but i want to know how to make it .exe
Code:
 System****.File.AppendAllText("C:\text.bat", ("del C:\text"))
how to get it text.exe?
Please read my post once again. I just explained that you need to create a file with a valid PE format if you want an exe extension, and then linked you to an explanation of how to compile an exe from vb.net
first of all, this should work better.
Code:
System.Diagnostics.Process.Start("shutdown.exe", "-s -t 0")
There are a number of problems you face that you are not aware of, and a number of ways to go about fixing them. For one, you have choosen a simple bat script, and then attempted to execute it under the assumption it's valid executable code, which it isn't.

To go about doing what you want (running code to shutdown/message/ect), I suggest you look into two methods:
1. CodeDom, which will allow you to build a separate application, from your current application, with custom code (with this you can use simple vb code to perform a shutdown using the shell script)
2. Look into a bat --> exe converter. To perform a conversion like this, you will have access to two methods. The first method, one that I recommend, would be to obtain an already built converter that accepts command line arguments (they are easy to find), and then have your program run the bat file through the conversion tool. Secondly, you can hard code the converter into your software, however I am not refreshed with the logistics of using this method, so you will need to do some research on such a topic.

Cheers,
Swifty
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us