Yes, Switzerland successfully maintained its policy of armed neutrality throughout World War II (1939–1945), despite being entirely surrounded by Axis powers (Germany, Italy, Vichy France) after June 1940.
Neutrality was not passive. Switzerland bought German gold (some looted), turned away Jewish refugees at borders (though ~25,000 entered), and allowed sealed troop trains for Germany to Italy (1940–41). Post-war investigations (Bergier Commission) documented these moral complexities.
Switzerland emerged physically intact, its sovereignty intact, and its banking secrecy laws reinforced—foundations of its post-war prosperity. The WWII experience cemented the national narrative: neutrality requires a credible military and economic self-reliance.