0

I have a site within a corporate portal (fully secure) that launches several applications tied to a certain business group. The problem I am having is one of the file paths I need to Launch has a ² in the path. This software is installed on more than 3000 computers across the globe, so changing the path inst very functional. Here is the snippet of code I am using:

<a href="javascript:LaunchApp1()">MC2 / ICE</a>

<script>

      function LaunchApp1() {
         if (navigator.userAgent.indexOf("WOW64") != -1 || 
            navigator.userAgent.indexOf("Win64") != -1 ){
            var ws = new ActiveXObject("WScript.Shell");
            ws.Exec('"C:\\Program Files (x86)\\MC² Software\\ice.exe"');
         }
         else {
           var ws = new ActiveXObject("WScript.Shell");
           ws.Exec("C:\\Program Files\\MC² Software\\ice.exe");
         }
      }

</script>

Any ideas on how to get around the squared character? Have extensively search everywhere.

Thanks!

Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68
pjparks
  • 1
  • 2
  • 1
    `C:\\Program Files\\MCSOFT~1\\ice.exe` .. What is wrong with the `²` character anyway? You have different locales which aren't in unicode? – Paul S. Jul 25 '13 at 16:49

2 Answers2

0

How about using the short filename instead? You should be able to convert the whole path to an MS-DOS-compatible path, which shouldn't include the pesky superscript 2, and use that instead. Theres another stackoverflow question asking how to convert a full path to a short path, and the simplest answer seems to be to run this in a cmd terminal in the directory in question:

for /d %I in (*) do @echo %~sI

The Microsoft support site also covers this topic.

Converting the directory name in question to the short form should yield this path:

C:\Program Files\MCSOFT~1\ice.exe

or

C:\Program Files (x86)\MCSOFT~1\ice.exe
Community
  • 1
  • 1
DaoWen
  • 32,589
  • 6
  • 74
  • 101
  • This worked as well. Any idea on how I get around the error of "the requested operation requires elevation"? Since we are in a corporate environment, I don't think users will have access to change and UAC controls. Thanks again for the answer. – pjparks Jul 25 '13 at 17:59
  • @pjparks - I don't really do scripting on Windows, so I have no idea. You should probably post that as another question though (or search for an already existing question). – DaoWen Jul 25 '13 at 19:16
0

http://www.fileformat.info/info/unicode/char/b2/index.htm

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals

looks like you may be able to get away with using a unicode replacement for your squared value, so it would look something like this for your path:

ws.Exec('"C:\\Program Files (x86)\\MC\u00B2 Software\\ice.exe"');
user2366842
  • 1,231
  • 14
  • 23
  • Both of these examples worked great. Thanks for the help. The only issue I deal with now is the error saying the operation requires elevation. But this only happens on a few machines. – pjparks Jul 25 '13 at 17:58
  • This would probably be worthy of a second question being opened. Unfortunately I don't know of any good way to force it to be ran as admin via a shell command. Glad I was able to help at least with most of the issue though. – user2366842 Jul 25 '13 at 18:48