The following windows 7 batch file script returns the error:
#ECHO OFF
if exist C:\Program Files (x86)\ E1\P45V goto WIN7
ren /s /c "c:\Program Files\ E1\P45V\P45Login.bmp" "c:\Program Files\E1\P45V\P45Login_OLD.bmp"
copy "\\locattion14\temp\E1\P45Login.bmp" "c:\Program Files\ E1\P45V\P45Login.bmp"
goto END
:WIN7
ren /s /c "c:\Program Files (x86)\ E1\P45V\P45Login.bmp" "c:\Program Files (x86)\E1\P45V\P45Login_OLD.bmp"
copy "\\locattion14\temp\E1\P45Login.bmp" "c:\Program Files (x86)\ E1\P45V\P45Login.bmp"
:END
The syntax of the command is incorrect
Using PSTOOLs to push out a change to computers, and will add the list when the syntax error is corrected.
The desired result:
If the pc is an XP machine, rename the P45login.bmp file to same name_OLD.bmp, then copy the file from loaction 14 into the directory noted.
If the PC is a Win 7 machine, skip the first part, go to the second part, and commit the same changes.
close the session.
I have moved quotes, added/subtracted switches, but arrive at the same error.
Surely it is just a simple syntax particularity that I am not catching.
Hoping someone will take a look, see the obvious I am missing, and point me in the right direction,.
Thank you for any help or suggestions.
Your ren syntax is wrong. ren does not support any switches and also rename_to needs to be name only, not full path. See full details here: http://technet.microsoft.com/en-us/library/cc754276%28v=ws.10%29.aspx
Additionally:
- if exists needs quotes around path
- you use both \ E1\ or \E1\ (with or without space). While both could be valid, I would double check if that's not an error.
- if the paths above are actually different, you need to use move (with full paths) instead of ren.
Related
i want to use
where /r C:\Program Files (x86)\ used.cs
but it says i can't use them! how can i use the program files x86 without that error!
please help fast
You forgot to quote your path, otherwise where can't know that Files or (x86) is part of the path and used.cs is not!
where /r "C:\Program Files (x86)" used.cs
I defined below command in jenkins windows batch command build step:
for /r %%f in (.\*.exe) do echo %%f
But the echo doesn't print the file name. Instead it just prints %f to the console.
I have tried with single % as below but it doesn't help. It prints f to the console.
for /r %f in (.\*.exe) do echo %f
How can I escape % character on jenkins build step? I am not sure whether it relates to jenkins only.
On Jenkins 2.60.2 on Windows 10, with two Firefox installer executables in my directory, running for /r %%f in (.\*.exe) do echo %%f in a Windows Batch command, I get the following output:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Test
[Test] $ cmd /c call C:\WINDOWS\TEMP\jenkins4832870824680456992.bat
C:\Program Files (x86)\Jenkins\workspace\Test>for /R %f in (.\*.exe) do echo %f
C:\Program Files (x86)\Jenkins\workspace\Test>echo C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.en-US.exe
C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.en-US.exe
C:\Program Files (x86)\Jenkins\workspace\Test>echo C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.exe
C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.exe
As you can see, it correctly treated the double %% as a single % when running the batch command, which makes sense, as it just calls cmd /c call on the temporary batch file that it creates, and that is the correct way of doing % syntax in a batch file.
I don't think it likely that this behavior would have changed much from different versions of Jenkins, but what version are you running? Can you post the full output of your batch command? Maybe there's something in there that can give us a clue.
We have several projects that have a "templates" folder that all get copied to the same "templates" folder in our shared bin directory. Intermittently we get xcopy failures.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "xcopy /s /y /r "E:\Source\DotNet\Service Providers\ActionScheduler\Templates" "E:\Source\DotNet\bin\x64\Release\Service Providers..\Templates\"" exited with code 4
These are post build steps that are being run in devenv.
I'm wondering if anyone has a suggestion to reduce or remove these errors.
Perhaps there is an alternative to xcopy which is more robust?
All of the templates folders that get copied have a subfolder "EN" and some files under that directory.
Additional information:
<message>98> Sharing violation</message>
<message>98> 0 File(s) copied</message>
<message>98> Unable to create directory - E:\Source\DotNet\bin\x64\Release\Templates</message>
<message>98>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "xcopy /s /y /r "E:\Source\DotNet\Service Providers\ActionScheduler\Templates" "E:\Source\DotNet\bin\x64\Release\Service Providers\..\Templates\"" exited with code 4.</message>
The error still occurred after adding /d. I also tried pre-creating the folder in a prebuild step of a project that would get build earlier. But I still got the following error:
98> Sharing violation
98> Unable to create directory - E:\Source\DotNet\bin\x64\Release\Templates
98> 0 File(s) copied
98>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4429,5): error MSB3073: The command "xcopy /s /y /r /d "E:\Source\DotNet\Service Providers\ActionScheduler\Templates" "E:\Source\DotNet\bin\x64\Release\Service Providers\..\Templates\"" exited with code 4.
You'll need to look in the Output window for a diagnostic message from XCopy when this error occurs. "Intermittent" is pretty hard to explain without that diagnostic.
There is certainly a good way to greatly reduce the chances for this going wrong. You are copying these files over and over again for no good reason. Add the /D option, that only copies when a file does not yet exist or has changed. So you basically only copy these files once and about never again, can't fail that way :)
After edit: yeah, that sure looks like two post-builds trying to copy the same file at the same time. Unlucky timing, anti-malware has a knack for extending it too long while it scans the file. You need to fix that, one is enough. With very high odds that /D already fixes it.
Code 4 means:
"Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."
Is E:\Source\DotNet\bin\x64\Release\Service Providers..\Templates\
OK? dotdot???
If you have several projects building the same output named support files you could try to turn off parallel builds. MSDN link for setting this option
However this looks like a system wide setting an not just for that project. As a last resort you could attempt to stop the copying of the files for all but one project by setting the "Copy to Output Directory" to "Do not copy".
I had a very similar issue, from the MSDN documentation here we added the following switches. Im my case the I switch seemed to do the trick.
Xcopy /Y /I /S
https://technet.microsoft.com/en-us/library/cc771254.aspx
Please have a look at the following commands and what was the error in syntax? i wanted to copy the dll file to my project bin directory
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\10.0.0.0__b03f5f7f1
1d50a3a>dir /s /b /o:gn
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\10.0.0.0__b03f5f7f1
1d50a3a\Microsoft.ReportViewer.WinForms.dll
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\10.0.0.0__b03f5f7f1
1d50a3a>copy Microsoft.ReportViewer.WinForms.dll C:\Documents and Settings\mural
i.madhava\My Documents\Visual Studio 2008\Projects\Rdclrender\Rdclrender\bin
The syntax of the command is incorrect.
Quite simply you need to place quotes around any path that has a space in it:
copy Microsoft.ReportViewer.WinForms.dll "C:\Documents and Settings\murali.madhava\My Documents\Visual Studio 2008\Projects\Rdclrender\Rdclrender\bin"
If you have spaces in your paths (such as C:\Documents and Settings), you'll need to surround them with quotes to stop them being treated as multiple arguments:
copy blah.WinForms.dll "C:\Documents and Settings\blah\bin"
This gives you the three-argument command:
copy
blah.WinForms.dll
C:\Documents and Settings\blah\bin
Without the quotes, you get the five-argument command which is not what you want:
copy
blah.WinForms.dll
C:\Documents
and
Settings\blah\bin
The following batch file, meant to parse a directory and send each file to the specified program, works in Windows Vista x64:
#ECHO OFF
FOR /F "tokens=1,2 delims=." %%A IN ('dir /b /on *.mts') DO (
"C:\Program Files (x86)\DGAVCDecode\DGAVCIndex.exe" -i %%A.%%B -o %%~nA.dga -f 2 -a -e
)
In Windows 7 x64, cmd returns "File Not Found"—both as a normal user and Administrator. What's going on?
You might want to use %PROGRAMFILES% instead of hard coding "c:\program files" into your batch file. For 64bit windows, there's also %PROGRAMFILES(x86)% which points to the 32bit program files directory.
I see the following problems in your code:
Looks like you use tokens=1,2 delims=. to split the file name by dot into the base name and extension and then join them back as %%A.%%B. This won't work with file names that contain dots, because it captures only the first two tokens from the file name. For example, given the file name foo.bar.mts, %%A.%%B will expand to foo.bar.
Moreover, this split/join isn't actually needed. If you use the loop without any parsing options, the file name is stored in the loop variable so that you can simply use that variable instead of %%A.%%B.
You need to enclose the file names passed to DGAVCIndex.exe in quotes, in case they contain spaces.
Also, I second Larry's suggestion to use %PROGRAMFILES(x86)% instead of C:\Program Files (x86) — it never hurts to use predefined environment variables instead of hard-coding standard system paths.
So, your code should look like this:
#echo off
for %%f in (*.mts) do (
"%ProgramFiles(X86)%\DGAVCDecode\DGAVCIndex.exe" -i "%%~f" -o "%%~nf.dga" -f 2 -a -e
)
This might seem obvious, but does DGAVCIndex.exe exist on the Win7 machine at the specified location?
Are you sure the folder names are correct with respect to the 32 bit and 64 bit versions of Windows 7. Did you check whether your batch file exists in the location that you have mentioned in the bat file.
Explorer mimics some directories like "C:\Program Files" and "C:\Users". When you use a localized windows 7, the directories have still the same name, but Explorer displays something localized like "C:\Programme" or "C:\Bemutzer".
Dont trust Explorer use the command line for copying files on a location you want to specify.