Feeds:
Posts
Comments

Posts Tagged ‘JavaScript’

To run an exe from your web page is quite easy process. I have used simple JavaScript to accomplish this task. Have a look at the code listed below.

function WriteToFile() {

var fso, s,folderName;

fso = new ActiveXObject("Scripting.FileSystemObject");

if (!fso.FolderExists("C:\\HITESH"))

{

folderName=fso.CreateFolder("C:\\ HITESH ");

}

if (!fso.FileExists("C:\\ HITESH \\LaunchApp.bat")){

s = fso.OpenTextFile("C:\\ HITESH \\LaunchApp.bat" , 8, 1, -2);

s.writeline("IF EXIST d:\\hitesh GOTO LABEL1”);

s.writeline("IF EXIST k:\\hitesh GOTO LABEL2”);

s.writeline(":LABEL1”);

s.writeline("D: ”);

s.writeline("D:\\hitesh\\AppTest.EXE”);

s.writeline("EXIT”);

s.writeline(":LABEL2”);

s.writeline("K: ”);

s.writeline("K:\\hitesh\\AppTest.EXE”);

s.writeline("EXIT”);

s.Close();

}

}

function LaunchApp() {

WriteToFile();

var oShell = new ActiveXObject("WScript.Shell");

var prog = "C:\\ HITESH \\LaunchApp.bat";

oShell.run ('"'+prog+'"',1);

}

This javascript will create an object of WScript.Shell and will execute DOS based batch file. In addition with this I have also created LaunchApp.bat file programmatically if it does not exist on the client side (So you don’t need to worry about whether file exist or not J). This file will execute EXE depending upon conditions specified in the LaunchApp.bat. LaunchApp() is the starting point.

Read Full Post »

This is common JavaScript error occurred while working with asp.net. I have faced this problem numerous times and believe me this is really very cumbersome error. This error occurs because of badly written JavaScript or due to access permission to the particular file, folder or image(s). Sometimes in your code if you have written path which does not exist in your .net web application. This kind error may occur. Friends, I have got this error many times and trust me each and every time its tuff to find where the problem is. Even my colleagues got this kind error many times. I have searched a lot about this error on Internet but not able to find the exact solution. Everybody is saying that it’s because of unclosed quotation mark in JavaScript. It’s true but not in every case.
 
In addition, what happens sometime you may not get this error while you work locally and the time when you deploy it to web-server you will get ‘unterminated string constant’ error. Am I correct ?
 
Here are the checklists/suggestions to resolve this error.
  1. Check you javascript for unclosed quotation mark. Check inline as well as reference JavaScript file. Starts with inline JavaScript.
  2.  

  3. Give proper permission (rights) to directory under which your aspx page laying. Ex. Rights for IIS user, ASP.net process.
  4.  

  5. Also check permission (rights) for image directory, if you are working with images.
  6.  

  7. Check for the hard coded path in the CS(Class file in C#) ,if any, check existence for the path.
  8.  

     

     

I hope the solutions above might be useful to resolve unterminated string constants error.

Read Full Post »