Solved

Troubles with Log off script

Posted on 2004-04-07
6
1,640 Views
Last Modified: 2008-02-01
I run a Windows 2000 Domain logoff script that backs up Outlook mailboxes from individual computers to the server.

I have two logoff scripts, basically, one logoff.vbs that calls another backup.cmd. Logoff.vbs asks for user input and if yes, it runs backup.cmd

Easy enough except that backup.cmd doesn't run. It stops at PKZIP and then exits very quickly.  I can't see what's on the screen. The script works fine when I scroll to the SYSVOL, then to my policy and click on logoff.vbs. Backup.cmd also works fine if I set it as logoff script in my domain policy and if it is not called from logoff.vbs. However, I need user input.

I spent two days trying to figure it out and I have no clue.

Logoff.vbs
========
Set wshShell = WScript.CreateObject("Wscript.Shell")

strInput = MsgBox("Do you want to backup your e-mail?", vbQuestion + vbYesNo, "Select Yes or No")

If strInput = 6 Then wshShell.Run("backup.cmd") ' They pressed Yes
If strInput = 7 Then WScript.Quit ' They pressed No
+++++++++++++++++++++++++

backup.cmd
========
@ECHO OFF

ECHO Backing up your email and address book to server
ECHO Archiving your file locally

C:
CD\
CD "Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook\"

PKZIP OUTLOOK.ZIP Outlook.pst

ECHO Copying file to server

COPY OUTLOOK.ZIP H:\Email\*.*

ECHO Done!

PAUSE
++++++++++++++++
0
Comment
Question by:njava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Expert Comment

by:JamesDS
ID: 10781535
njava

Put a pause command before and after the PKZIP command and post the error message - if there is one
Cheers
JamesDS
0
 
LVL 84

Accepted Solution

by:
oBdA earned 100 total points
ID: 10781903
You don't wait for the batch script to end, so your VB script finishes, and the logoff continues and shuts down the zipping.
Make that "wshShell.Run("backup.cmd",,true)

Windows Script Host: Run Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthrun.asp

Then there's an error in your batch file: The proper environment variable to get access to the user's profile folder is %UserProfile%; this folder is *NOT* necessarily "Documents and Settings\%Username%"!
CD "%UserProfile%\Local Settings\Application Data\Microsoft\Outlook\"
0
 
LVL 16

Expert Comment

by:JamesDS
ID: 10781952
oBdA

Nice answer, I stand in awe!

Cheers

JamesDS
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 3

Expert Comment

by:roadhog_NZ
ID: 10786594
no idea really... but is the PKZIP command in the correct order? PKZIP Outlook.pst OUTLOOK.ZIP ??
0
 
LVL 3

Expert Comment

by:roadhog_NZ
ID: 10786611
DOH! ~(8(|), gotta stop staying up so late, and gotta start reading the questions better, backup.cmd does work.
0
 
LVL 1

Author Comment

by:njava
ID: 10788058
oBdA:
That was indeed the problem!!! I have a couple of notes.

1.  "wshShell.Run("backup.cmd",,true)" won't work - it will exit with error saying that you cannot use parenthesis when calling a Sub. The same line without parens should be used:

wshShell.Run "backup.cmd", 0, true

2. After I fixed wshShell.Run and attempted to run logoff.vbs I got another error
"The procedure entry point DoOpenPipeStream could not be located in the dynamic link library ScrRun.dll".

It happened because the version of scrrun.dll in %windir%\system32 was 5.0 and it should be 5.6 for the script to work.
"regsvr32 scrrun.dll" didn't fix the problem, so I downloaded Windows Scripting Machine (it's not the exact title but close) from Microsoft's website and voila, the script worked like a charm. Surprisingly though, my computer was the only one of 25 that had problems with scrrun.dll
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
There is less than 0% available RIDs in the current pool 5 779
P2V Windows NT/2000 SP4 3 1,832
Images sometimes not printed 6 489
P2V conversion for Windows NT 4.0 Server 2 2,315
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

761 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