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.
Deleting file on desktop, waiting for a program to be closed
Moderator: DosItHelp
-
- Posts: 5
- Joined: 05 Aug 2009 06:50
Deleting file on desktop, waiting for a program to be closed
Last edited by QE_LiTHiUm on 06 Aug 2009 03:23, edited 1 time in total.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
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:
del "%userprofile%\desktop\a.txt"
del "%userprofile%\start menu\a.txt"
should work in both Vista and XP (not completely certain)
copy thisfile.cmd "%programfiles%"
copy thisfile.cmd "%userprofile%\start menu\startup"
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.
So:
I don't think the above items will be needed.- 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
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"
start "title" /wait "yourexternalprogram.exe"- 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.
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.
-
- Posts: 5
- Joined: 05 Aug 2009 06:50
-
- Posts: 5
- Joined: 05 Aug 2009 06:50
-
- Posts: 5
- Joined: 05 Aug 2009 06:50
Ok, I was trying all night till now, and I got my answer for the time problem :
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.
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.
-
- Posts: 5
- Joined: 05 Aug 2009 06:50