Command or switch to use to ask for Yes to continue or No

  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

Hi, I'm using an xcopy .bat file to copy files over to the server when a user log of to go home for the day. My xcopy bat file is straight forward: Here is an example:

xcopy /d /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "H:\USERS\%USERNAME%\Outlook"

The problem I have is that sometime a user will need to log off their station mid-day. When they do, this .bat file runs and most time it takes 5-15 mins for it to run before logging off. User can manually turn off their system but do not want to. I'm looking for a way to his this batch file prompt the user if they would like to run this batch file when they log off.

For example: The user logs off. The batch starts and prompts the user. Do you want to run this: Y for Yes or N for N.
(Y) runs the batch file
(N) cancels and log off the user.

Is there a way this can be done? Choice command was an option but I'm using XP Pro SP2.

Can someone tell me or better yet right down what needs to go in front of my example. Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Code: [ Select ]
@echo off
ECHO Do you wish to allow this batch file to run?
ECHO Press CTRL + C to cancel or
PAUSE

REM Rest of your batch file code here goes here
  1. @echo off
  2. ECHO Do you wish to allow this batch file to run?
  3. ECHO Press CTRL + C to cancel or
  4. PAUSE
  5. REM Rest of your batch file code here goes here


The PAUSE will cause the script to stop and display "Press any key to continue". If they hit CTRL+C they'll be asked to end the script or not. If they enter Y the script will exit, otherwise it will continue. I did try this on XP SP2 and it works just fine.
  • lucassix
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2350
  • Loc: Indiana

Post 3+ Months Ago

You could use the SET command to set an enviroment vairable

Code: [ Select ]
@echo off
:begin
SET /P runscript="Do you wish to run the logoff script at this time? (Y/N) "
if %runscript%==y goto run
if %runscript%==Y goto run
if %runscript%==n goto end
if %runscript%==N goto end
goto begin
:run
xcopy /d /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "H:\USERS\%USERNAME%\Outlook"
:end
  1. @echo off
  2. :begin
  3. SET /P runscript="Do you wish to run the logoff script at this time? (Y/N) "
  4. if %runscript%==y goto run
  5. if %runscript%==Y goto run
  6. if %runscript%==n goto end
  7. if %runscript%==N goto end
  8. goto begin
  9. :run
  10. xcopy /d /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "H:\USERS\%USERNAME%\Outlook"
  11. :end




Or you might want it to timeout it incase they just logoff and walk away. An easy way to make a timeout in a batch file is with an invalid PING command.



Code: [ Select ]
@echo off
echo The logoff script will run in 10 seconds
echo.
echo To cancel this action, press Control-C
ping 1.1.1.1 -w 10000 -n 1 >nul
xcopy /d /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "H:\USERS\%USERNAME%\Outlook"
  1. @echo off
  2. echo The logoff script will run in 10 seconds
  3. echo.
  4. echo To cancel this action, press Control-C
  5. ping 1.1.1.1 -w 10000 -n 1 >nul
  6. xcopy /d /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\mailbox.pst" "H:\USERS\%USERNAME%\Outlook"
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

Hi, thanks for all the replies. One thing I forgot to mention is that this script is set to run when the user logoff the system through Group Policy in the logoff/logon in windows configuration on the clients. So when a user log off
they don't see anything except a windows prompt that says. Logoff scripts are running.

So then what happen is the system will stay on until the user respond to the prompt, which they can't because they are already log off.

I hope this makes sense. Is there another way? I can create a batch icon on the desktop and have the user click on it to run the script but then I know the users will most time not do that.

Any other ideas?
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

Hi, sorry I didn't see the second post until I posted my response. Anyway, I tried those two and pretty much I'm still in the same area. The one with the timeout works great but when I use it within the group policy I can't stop the script from running. Because it runs after a certain time, the system doesn't wait for me to respond. How can you bring the batch up during logoff so a user can end it? I tried contol C but that didn't stop it.

I wonder when running logoff scripts, is the keyboard disable? Or is it because since I can't see the batch file running in the background I can't end it.

Thanks
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6809
  • Loc: Martinsburg, WV

Post 3+ Months Ago

Why don't you just use folder redirection to copy their PST to their home folder which is what it looks like you are doing.

Open up your Group Policy and go to User Configuration/Windows Settings/Folder Redirection/Application Data. Right click Application Data and select properties. You can then redirect everyone's Application Data to the shared folder their home folders are set to.
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

Folder Redirect will not suite what we are doing here.
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6809
  • Loc: Martinsburg, WV

Post 3+ Months Ago

Yes it will. It is designed to do precisely what you are doing with your bat file.

All your doing is copying their PST which lies in the application data folder of their profile to a mapped drive which would be a share on a file server.

This completely eliminates the need for a logoff script.

Another option is to download the Office 2003 Resource Kit (if you are using Outlook 2003) and import the Outlook .adm file into your Group Policy. Once done navigate to User Configuration/Administrative Templates/Microsoft Office Outlook 2003/Miscellaneous/PST Settings. Within there you can specify the location of their pst files. This completely eliminates the need to move their PST when logging off, it will always be there. Office 2000 and 2007 have the same thing but I am more familiar with 2003.
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

We will not be using folder redirect. There is a reason why we have the pst on the client. Thanks for suggesting folder redirect.

Any ideas on the script?
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6809
  • Loc: Martinsburg, WV

Post 3+ Months Ago

What reason is that? What your doing is a waste of resources when you can do it automatically through Group Policy. My personal professional opinion there is no real need to have the PST on the local machine unless they are on a laptop but then there is always offline folders and all that good stuff.

Whatever floats your boat though.

Not sure if this will help or not but take a look at this guys script, you might be able to use it.

http://www.themsoffice.com/backup-your- ... -pst-file/
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

Thanks for the link... Looks interesting and would work to an instant. Anyway, we have an AS400 file database server. We are running a workgroup environment. We have about 50 XP users. Most user's .pst file are over a gig and some even up to about 2 gig depending on what version of Outlook they have.

I have suggested to have the .pst file located on the server instead on the clients. Therefore there would be no need for backing up the .pst to the server. Backups would only be done on the server side. The problem is, because of the huge .pst size and users hitting the box it causes a daily when opening Outlook and also a strain on the server box.

Yes, an exchange server is what we need but this is out of my hands. I'm just the lucky guy who ends up fixing or finding a workaround with this pc problems.

The whole problem with this is, if I can't find a solution then we will be reverting back to Lotus Notes. (And that is a whole set of another problem)

Thanks again.
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6809
  • Loc: Martinsburg, WV

Post 3+ Months Ago

You have 50 XP users in a workgroup? Microsoft only recommends 10, beyond that it becomes a nightmare to manage. But then how are you using Group policy in a workgroup. I seriously doubt you are running around to every client machine and editing the local group policy, that would be silly.

An Exchange Server won't solve your issues with pst's. What you can do though is restrict the size of the pst and force people to delete e-mail.

Another question is why are people running different versions of Outlook?

My company is currently using Outlook 2000. I use a PST to store files I need to keep and keeping my inbox file size small since my company employes mailbox size restrictions. I setup my pst to reside in my Home folder which is on a file server somewhere.

If I am not mistaken, Outlook 2003 stores everything in a pst if you are not connected to an Exchange Server. Not sure how 2007 does it but probably similar.

Running in a Domain environment with Exchange would be your best bet and let your higher ups know that Exchange is cheaper to maintain than Lotus. I hate Lotus.
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

That's right... 50 Xp users with an AS400 File Database. I'm working on implementing a windows 2003 server but it's still in test mode. I'm still having some hiccups there with folder redirect.

Anyway, yeah I'm running around the entired building updating this manually one by one either from scripts, updates, new sofwares ect... It's a nightmare. The group policy i'm using are the local ones on the PC.

For pst size... Yes, I agree there should be a size limitation but unfortunately that is also something I've got no control over. The good thing is 2000 Outlook only allows a max of 2 gig, well more like 1.8 before it starts acting up. 2003 Outlook allows up to 20 gig. The difference in software is because some users get extra points for being executives of the company. Any why not everyone getting the newiest version - well it's about money with this company.

Anyway, Exchange is something I want but I don't see it any time soon. It took me two years to presuave them to let me moved from a workgroup to a domain. And even now, I don't have the hardware I need to set up a 2003 server. I'm running my test on a 2000 server. Yes, a waste of time to test on a 2000 server when i'll be implementing a 2003 server.

Bottom line is, I don't have the resource to do my job. And resource I need takes time to get. I really long long time.
  • grinch2171
  • Moderator
  • Genius
  • User avatar
  • Posts: 6809
  • Loc: Martinsburg, WV

Post 3+ Months Ago

I feel bad for you then.

It would probably make you sick to know that I have 3 dual quad-core servers with 4Gb of RAM and 1.8 TB of hard drive space just sitting in a box with nothing to do. Each cost somewhere around $25,000 a piece.
  • rsn00
  • Beginner
  • Beginner
  • rsn00
  • Posts: 52

Post 3+ Months Ago

LOL... Our 2000 server has 512mb ram and 20 gig HD.

Post Information

  • Total Posts in this topic: 15 posts
  • Users browsing this forum: No registered users and 55 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.