Solved

Error "cscript exited with error code 0" when running vbscript from batch

Posted on 2009-04-03
4
5,074 Views
Last Modified: 2012-05-06
I am trying to create a batch that closes outlook "correctly" on client machines from the server.  I know killing outlook would be easy enough, but i don't want outlook scanning files every morning when my users open it up because it was not closed properly.  

I found a vbscript that closes outlook, and I am now trying to execute it from a batch.  I am currently testing on 2 XP machines, to determine if this is going to work.  So far, no luck.

Here is the script that closes outlook:

On Error Resume Next
Set Outlook = GetObject(, "Outlook.Application")
If Err = 0 Then
Outlook.Quit()
End If

When I execute this locally, it works fine.

Here is the test batch that I have created to run remotely:

psexec \\station1812 cscript "c:\test\testscript.vbs"

When I run this from a remote computer I get the following error "cscript exited with error code 0"

Any suggestions?  Thanks in advance!

0
Comment
Question by:omniumnetworking
  • 3
4 Comments
 
LVL 17

Expert Comment

by:Jared Luker
ID: 24061901
Error code 0 means that it thinks it completed successfully.  I think the problem that your having is with psexec and not the batch file
0
 
LVL 17

Expert Comment

by:Jared Luker
ID: 24061917
Maybe try to change your quotes, or no quotes...

psexec \\station1812 "cscript c:\test\testscript.vbs"
 
psexec \\station1812 cscript c:\test\testscript.vbs

Open in new window

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 24061929
Yes - psexec is running it under 'your' credentials.
Since the outlook session is running under another user's context, you won't be able to get to it using psexec.

Probably a better idea would be to set up a logon script for the user(s) that adds a schedule task (if they have rights to create a task) under their credentials to occur at a specific time of day...
0
 
LVL 17

Expert Comment

by:Jared Luker
ID: 24061959
Another thought is creating a logoff script that executes the VBSCript to make sure that outlook closes when they logoff/reboot at night.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question