Click here to Skip to main content
11,707,254 members (48,857 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
My question is how do you run a file as .exe.
It may sound simple but it isn't. I am not talking about this:
Process.Satrt("anything.exe")
My question is :
Suppose I have a file called a.txt and when i click a button it runs as a.exe not a.txt
In other words it is a Temporary File Converter.
Any Code for that????


OP's additional information moved from non-solution below
See what i am telling is that in WINDOWS EXPLORER you can rename a.txt to a.exe or a.bat
or a.cmd and then execute it.I want to do the same with VB.NET 2010 EXPRESS.
I need it for my program "RUN AS ANYTHING".
Also i have tried this but i failed :
Button1_Click
Dim O as New OpenfileDialog
o.showdialog
Process.start(Openfiledialog.Filename + "exe")'For running the program or a file in exe format
Posted 13-Dec-12 0:27am
sid2x1.1K
Edited 15-Dec-12 2:28am
Nelek74K
v2
Comments
Aarti Meswania at 13-Dec-12 6:45am
   
not a clear question

we can not run txt file as exe
do you want to ask for executing batch files or any else?

please explain briefly and post here code which you have tried... :)
01010RAJ at 13-Dec-12 6:53am
   
not right.
Ashok19r91d at 17-Dec-12 2:36am
   
Files and Programs are different, All Programs are files, But Not all Files are Programs, so You can't Execute Files as Executable Application... But you can use Default Program to View or Open File, For Example Notepad for txt file, For that Use
Process.Start(O.FileName) ' Assuming O as OpenFileDialog...

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is no built in way to do that, and I can't see any (non-malicious) reason why you would want to.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 141
1 Sergey Alexandrovich Kryukov 135
2 chainerlt 110
3 Maciej Los 80
4 ppolymorphe 79
0 OriginalGriff 9,178
1 Sergey Alexandrovich Kryukov 8,512
2 CPallini 5,189
3 Maciej Los 4,766
4 Mika Wendelius 3,696


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 15 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100