I'm making a batch-file which is supposed to run several batch-files. The problem is that it runs the first batch-file, and then quits
echo "Running SharePoint.Access\buildPackageAndCopy.bat..."
call SharePoint.Access\buildPackageAndCopy.bat
echo "Running SharePoint.Admin\buildPackageAndCopy.bat..."
call SharePoint.Admin\buildPackageAndCopy.bat
echo "Running Sharepoint.Levels\buildPackageAndCopy.bat..."
call SharePoint.Levels\buildPackageAndCopy.bat
I'm sure i have an enter-line between all the commands.
This is one of the batch-files I am running
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
cd /d C:\src\SharePoint\
msbuild /p:IsPackaging=True
md c:\temp\_wsp
xcopy Core\bin\Debug\SharePoint.Core.wsp c:\temp\_wsp /y
xcopy Definitions03\bin\Debug\SharePoint.CustomDefinitions01.wsp c:\temp\_wsp /y
xcopy CustomLists02\bin\Debug\SharePoint.CustomLists01.wsp c:\temp\_wsp /y
xcopy Customs01\bin\Debug\SharePoint.CustomPresentation01.wsp c:\temp\_wsp /y
Try commenting out the content of the first batch file and see if the second one now runs. That way you'll know whether something in the first one is aborting it.
Related
Created a GPO to run a batch file on shutdown for domain XP computers - with the purpose of deleting old user profiles.
For this I am using an application called DeleteProfiles from OptimumX.
cd C:\
if exist "Program Files (x86)" GOTO Exit (Checks if XP or not)
if exist DeleteProfiles GOTO COMMAND
:CopyDeleteProfiles
md DeleteProfiles
copy /Y \\SomeShare\SomeFolder\DeleteProfiles\DeleteProfiles.exe
C:\DeleteProfiles\
:COMMAND
pushd C:\DeleteProfiles\
start /Wait DeleteProfiles.exe /MIN:14 /Y
rem (/Min: # = Delete profiles older than # and /y removes yes or no prompts)
:Exit
End
It works alright, but a CMD window appears at shutdown with the output of the program.
How do I make it go away?
The real problem here is that users can close the program which causes the script to stop. If I can't make that go away, I would like at least to make the window not close-able.
Looked up start /?, adding the /b parameter does the job
start /b /Wait DeleteProfiles.exe /MIN:14 /Y
This is going to be hard to explain, I'll try my best.
I'm using a shell scripting (Test Executor) in command prompt to automate our regression testing. However i'm stuck on one thing.
Basically I have to copy this dynamically created folder in a location into another folder after the automated script is done (in CMD via scripting)
:: create an achieve directory
#SET ACHIEVE_DIR=C:\Test Result\LOG_Files
mkdir "%ACHIEVE_DIR%"
xcopy /y /s /e "%TEST_SOURCE_DIR%"\*.* "%ACHIEVE_DIR%"
This will copy all the files in the TEST_SOURCE_DIR, but i only want this dynamically created folder which changes according to the date stamp (BUT this date stamp is calculated by second - so i can't use that as a variable).
For example: After i run a test it'll create a folder under lets say C:\temp\ another folder named "TEST RUN - _2014-06-30 15_48_01_"
So if go into C:\temp i'll find a folder named "TEST RUN - _2014-06-30 15_48_01_" along with other folders. BUT i only want to copy this dynamic folder into Test Result\LOG_Files
What we are given is that the starting string will always be "TEST RUN -" but the ending string will interchange according to the time to the second (BUT we cannot go by that since it is the second of the starting test result).
I found out if i am in command prompt and i type in "cd TEST RU" and hit tab it'll finish it for me "cd TEST RUN - _2014-06-30 15_48_01_" Is there a way to script this tab hit or something?
Thanks!
This should work in a batch file to isolate the folder:
If there are a number of folders starting with test run - then tell us.
#echo off
SET "ACHIEVE_DIR=C:\Test Result\LOG_Files"
cd /d "c:\temp"
for /d %%a in ("test run -*") do xcopy "%%a\*.*" "%ACHIEVE_DIR%\" /s/h/e/k/f/c
This code looks for a test folder as discussed in the comments:
#echo off
SET "ACHIEVE_DIR=C:\Test Result\LOG_Files"
cd /d "c:\temp"
for /d %%a in ("test run -*") do (
pushd "%%a"
for /d /r %%b in ("test*") do (
xcopy "%%b\*.*" "%ACHIEVE_DIR%\" /s/h/e/k/f/c
)
popd
)
This batch file should do the job:
#echo off
rem Find the directory starting with "TEST RUN -" created last in C:\Temp.
set ACHIEVE_DIR=C:\Test Result\LOG_Files
for /F "usebackq delims=" %%D in ( `dir "C:\Temp\TEST RUN -*" /AD /B /O-D /TC` ) do (
set TEST_SOURCE_DIR=%%D
goto CopyDir
)
echo No directory starting with "TEST RUN -" found in C:\Temp.
pause
exit /b
:CopyDir
rem Copy all files and subdirectories from last test run to achieve
rem directory whereby xcopy automatically creates the achieve directory.
xcopy /E /I /Q /S /Y "%TEST_SOURCE_DIR%" "%ACHIEVE_DIR%"
set ACHIEVE_DIR=
set TEST_SOURCE_DIR=
Read the Microsoft pages about
dir
for
xcopy
for details about the used parameters of those 3 commands.
Or execute in a command prompt window the commands
dir /?
for /?
xcopy /?
one after the other to get the shorter help for those 3 commands output in the window.
I wrote a batch file for open a specific program but it is not working.I wrote this :
#echo off
C:\Windows\System32\cmd.exe /K "cd /d C:\Program Files (x86)\HTC\HTC Sync Manager\"
start HTCSyncManager.exe
When I run the batch file only this window come, program do not start. How to fix this
#echo off
For /r c: %%f in (path goes here /HTCsyncmanager.exe) do (
start "%%f"
"%%f"
)
Remove the invoking of cmd.exe. All that's doing is starting a new instance of the command processor, which is not what you need at all. (You probably don't need the start, either.)
#echo off
cd /d "C:\Program Files (x86)\HTC\HTC Sync Manager\"
HTCSyncManager.exe
#echo off
start "HTCSyncManager" "C:\Program Files\(x86)\HTC\HTC Sync Manager\HTCSyncManager.exe"
This will open HTCSyncManager.
Here is my code. All the files are exactly where im pointing to, except in the end after running the .bat file, it says that SPSupport.BHF is not found and when I go into the directory, SPSupport.BHF is not there. any ideas on what's wrong? Basically, if it's windows 7, it downloads the windows 7 file in a certain location, other wise it downloads the windows xp file. I'm using a windows xp computer and when I run the .bat file, in the cmd it prints out all of these commands correctly except on the last step when I try to run it, it says internal or external command not found and when I go into the directory, the files aren't even copied successfully.
Note: It also says "UNC paths are not Supported. Defaulting to Windows Directory" at the begging. could that be why? What does that mean?
#echo off
mkdir C:\Windows\Temp
if exist "C:\Users\" goto win7
if exist "C:\Documents and Settings\" goto winxp
:win7
xcopy /s /Y \\torwan\Shared\SPSupport.BHF C:\Windows\Temp
xcopy /s /Y \\torwan\Shared\PCA.megamation.CIF C:\Windows\Temp
START C:\Windows\Temp\SPSupport.BHF
goto exit
:winxp
mkdir "C:\Documents and Settings\All Users\Application Data\Symantec\pcAnywhere"
echo d xcopy /s /Y \\torwan\Shared\xp\SPSupport.BHF "C:\Documents and Settings\All Users
\Application Data\Symantec\pcAnywhere"
echo d xcopy /s /Y \\torwan\Shared\xp\PCA.megamation.CIF "C:\Documents and Settings\All Users
\Application Data\Symantec\pcAnywhere"
"C:\Documents and Settings\All Users\Application Data\Symantec\pcAnywhere\SPSupport.BHF"
PAUSE
goto exit
:exit
Can you run the bat file from the local machine instead of running it from a network drive? You have an extra space between Application and Data in "C:\Documents and Settings\All Users\Application Data\
I have following script that executes all the .reg files in the current directory. the problem is i also have sub directories in that folder and i want to execute those reg files as well. I am not sure what switch i am supposed to use. i tries using /s which returns all the .reg files of the drive.
this is how my batch file looks like:
rem #echo off
cls
SET folder=%~dp0
for %%i in ("%folder%*.reg") do (regedit /s "%%i")
echo done
pause
EXIT
This is how file/directory structure looks like:
Folder1
batchfile.bat -> user double clicks or executes from command prompt
1.reg
2.reg
3.reg
Folder2
4.reg
5.reg
what am i missing here?
I think that you need a recursive for loop using the /R switch:
for /R "%folder%" %%i in (*.reg) do (regedit /s "%%i")
You didn't actually say what your problem was, so instead of fixing your script here's what I would have done:
#echo off
set folder=%~dp0
for /f "usebackq" %%i in (`dir /s /b *.reg`) do (
regedit /s "%%i"
)
And the /s script on regedit is for silent mode. It tells regedit not to ask the user for confirmation with a dialog box. The for loop is what causes the batch file to loop through all subdirectories, not the /s switch on regedit.
From Microsoft's Knowledge Base:
[/s|-s]
When a filename is specified on the command line, this switch is used to
suppress any informational dialog boxes that would normally be displayed.
This is useful when the Setup program for an application wants to execute
REGEDIT.EXE with a .REG file, but does not want the user to be confused by
any dialog boxes that are displayed.