Hello World example on Windows 10

I recently installed the toolchain on Windows 10. Had no problem generating hello_world project using cargo. restc the main.rs which contains the ubiquitous "hello world" code and then tried to execute the .\main.exe and got the following.

ResourceUnavailable: Program 'main.exe' failed to run: An error occurred trying to start process 'C:\Users...\rust-projects\learning\hello_world\src\main.exe' with working directory 'C:\Users...\rust-projects\learning\hello_world\src'. Access is denied.At line:1 char:1
.\main.exe

Also the main.exe was deleted after I got this error. Anyone experience this before?

It looks like antivirus has flagged main.exe and automatically removed it. Developers run into this all the time with compiled languages because antivirus software really doesn't like running unknown programs from an "unknown" origin (i.e. something that didn't come from an installer with signed binaries).

What you do next will depend on the antivirus you use, but sometimes you can make it ignore the output from certain programs (i.e. rustc and cargo) or ignore certain folders.

2 Likes

Yep, you were correct. The machine I'm working on is an enterprise controlled machine. I disabled antivirus and tried again with the same result but then I looked a little closer and found that the enterprise security folks had pushed crowdstrike onto the machine. A short conversation with the info. sec. people got them to setup an exception directory on my machine that allows me to compile and run programs. Thanks for the assist. Very much appreciated.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.