×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Kill Excel Object Brio 6

Kill Excel Object Brio 6

Kill Excel Object Brio 6

(OP)
Hi All,

I have the following function which I put together by skimming this very helpful folders. Basically from my understanding is the function creates a vbs script and kills the last Excel process which is perfect for my needs. My problem is it doesn't seem to activate the script on the PC. I was wondering if someone could look at the code below and offer any pointers. Thanks for your time

CODE

var wsh = new JOOLEObject("WScript.Network");
var user = wsh.UserName;
strkillExcelfile = "C:\\Documents and Settings\\" + user + \\My Documents\\Brio Reports\\KillExcel.vbs

function killExcel(strkillExcelfile){
try{
// Defining vbs filename and destination
// creating file system JooleObject
var oScripting = new JOOLEObject("Scripting.FileSystemObject" );
// creating text file to receive vbs scripting
var oVBSFile = oScripting.CreateTextFile(strkillExcelfile);
// defining string with the vbs code
var sVbScript = "strComputer = \".\"\r\nSet objWMIService = GetObject(\"winmgmts:{impersonationLevel=impe rsonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\nSet colProcessList = objWMIService.ExecQuery (\"Select * from Win32_Process Where Name = \'EXCEL.EXE\'\")\r\nDim Counter\r\nCounter = 0\r\nFor Each objProcess in colProcessList\r\nCounter = Counter + 1\r\nif Counter = colProcessList.count Then\r\nobjProcess.Terminate()\r\nEnd if\r\nNext";

// writing vbs code to text file and saving as vbs file
oVBSFile.WriteLine(sVbScript);
// closing file
oVBSFile.Close();
Console.Writeln(strkillExcelfile)
// executing file
Application.Shell(strkillExcelfile);
}
catch(e)
{
throw e.toString();
}
}
fKillExcel = killExcel

fKillExcel (strkillExcelfile)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close