Deleting file on desktop, waiting for a program to be closed

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
QE_LiTHiUm
Posts: 5
Joined: 05 Aug 2009 06:50

Deleting file on desktop, waiting for a program to be closed

#1 Post by QE_LiTHiUm » 05 Aug 2009 07:03

Hi, I've searched this forum for almost 4 hours and finally I decided to join this great forum. I'm surprised to see how qiuch the answers coming up, it's great.

I want to make a batch file which does :

- Finds the version of the dos being used... ( I know it's done by the ver command)

- Checks if the dos belongs to Vista or XP by the version number... ( XP's dos version is "5", But Vista's dos version is "6")

- Check the username of the current user, using windows ( for example Administrator ). this one will be needed in the next 2 steps.

- If it belongs to XP deletes for example a.txt placed in the desktop and in the startmenu folder

- If it belons to Vista deletes for example a.txt placed on the desktop and in the startmenu folder

- Copy itself to the program files directory and startmenu

- Checks if the above is done, then jumps to the next step. ( for the nest uses of this batch, because it already has done all the above.)

- Sets the time of the system to a specified time and date.

- Runs an external program.

- Waits for the application in the previous step to be closed

- Returns the time and date to the original one.

So much thanks. Please answer this question, it's very important for me. thanks again.
Last edited by QE_LiTHiUm on 06 Aug 2009 03:23, edited 1 time in total.

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 05 Aug 2009 10:37

I believe that Vista and XP both still use %programfiles% and %userprofile% and %allusersprofile% . . ? Correct me if I'm wrong (don't have a Vista machine around here to check with).

So:

- Finds the version of the dos being used... ( I know it's done by the ver command)

- Checks if the dos belongs to Vista or XP by the version number... ( XP's dos version is "5", But Vista's dos version is "6")

- Check the username of the current user, using windows ( for example Administrator ). this one will be needed in the next 2 steps.
I don't think the above items will be needed.

- If it belongs to XP deletes for example a.txt placed in the desktop and in the startmenu folder

del "%userprofile%\desktop\a.txt"
del "%userprofile%\start menu\a.txt"
should work in both Vista and XP (not completely certain)
- If it belons to Vista deletes for example a.txt placed on the desktop and in the startmenu folder

- Copy itself to the program files directory and startmenu

copy thisfile.cmd "%programfiles%"
copy thisfile.cmd "%userprofile%\start menu\startup"
- Checks if the above is done, then jumps to the next step. ( for the nest uses of this batch, because it already has done all the above.)

- Sets the time of the system to a specified time and date.

- Runs an external program.

- Waits for the application in the previous step to be closed
start "title" /wait "yourexternalprogram.exe"
- Returns the time and date to the original one.


Maybe that will help you. I'm sorry that I'm not better with Vista, so I can't tell you too much about more help.

QE_LiTHiUm
Posts: 5
Joined: 05 Aug 2009 06:50

#3 Post by QE_LiTHiUm » 05 Aug 2009 12:04

Thanks very much larry for your kindness and your help.

I don't have time right now,I'll examine that and I will post the result, Thanks again.

QE_LiTHiUm
Posts: 5
Joined: 05 Aug 2009 06:50

#4 Post by QE_LiTHiUm » 05 Aug 2009 14:23

Thanks for the help, it worked even in Vista, except the time setting and returning function, which you forget to mention.
Any suggestions for this part ?

QE_LiTHiUm
Posts: 5
Joined: 05 Aug 2009 06:50

#5 Post by QE_LiTHiUm » 05 Aug 2009 16:06

Ok, I was trying all night till now, and I got my answer for the time problem :

Code: Select all

set da=%DATE%
date 08/06/2015
start "title" /wait "myrogramtorun.exe"
for /f "tokens=2 " %%a in ("%da%") do set number=%%a
date %number%



And it works just great for me, thanks to you larry.
Now I'm going to examine the whole program..... Hope it works fine too.

QE_LiTHiUm
Posts: 5
Joined: 05 Aug 2009 06:50

#6 Post by QE_LiTHiUm » 06 Aug 2009 03:26

Thank you all dostips.com forum.... I finally finished my project by your help..... ( especially larry ).

The reply was so fast, as I excepted from this forum.
I changed the name of the topic to be relevant to it's contents, maybe it will help somebody someday.

Thanks again.

Post Reply