Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
89 views
in Technique[技术] by (71.8m points)

c# - Create Executable from Visual Studio

I am trying to do something which should be simple, but I am having difficulty finding the resources in. I want to create either a .VB or .CS simple script in visual studio without a form interface to later be used an an executable to be ran in windows. I created the script in .vbs but since that is not a compilable language I can't make it a .exe from it.

The final idea is for the .exe to simply create some folders and move some files around without any popups for the client. Here is some of the simple .vbs code I made I am just trying to migrate over into Visual Studio compliable format.

Set fso = CreateObject("Scripting.FileSystemObject")

'Delete a Folder
If fso.FolderExists("C:Program Files (x86)Something") then
    fso.Deletefolder "C:Program Files (x86)Something", True
End IF

fso.CopyFolder "C:Program Files (x86)Somethingelse", "C:empDestination", True
question from:https://stackoverflow.com/questions/65942212/create-executable-from-visual-studio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The trick is to create a Console application and then to change the output type to "Windows Application" (in a C# project). Such an application will neither show a console nor a form window.

To change the output type, right click the project to open its properties. On the "Application" page there is a combo box named "Output type:". Select "Windows Application" from the drop down list.

It's the same in a VB project, except that the combo box is named "Application type:". Also you must select the "Startup object:". Most probably it will be "Sub Main".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...