individual command running but not batch file - windows

I have the below command which runs perfectly fine on command prompt
start "heythere" "c:\script\ABC.XYS.CreateXML.exe" -SiteCollectionUrl:"http://site-prd" -TargetPath:"C:\destFolder" -LoginName:"GLOBAL\username"
However when I save the exaack command in a batch file and execute it, it doesn't run at all
I really can't figure out the problem.

I finally figured it out. As the contents of the file were generated via code, there were issues with its encoding. Thus changing the encoding to ASCII solved the issue.

Related

Running a batch file through command prompt - system cannot find the path specified

I am trying to uninstall Oracle on this Windows 7 (64 bit) machine by downloading a standalone tool from Oracle, I need to run a batch file that is supposed to uninstall but I am unable to run it.
I tried to open command prompt as administrator and I am trying to run this as below:
As you can clearly see from the screenshot, I am doing a "dir" on the directory and can clearly see the file right there. Not sure what's going on here.
I also tried to run the batch file by double clicking from Windows Explorer and a terminal window opens and closes quickly but the batch file is not doing what it is supposed to do (it is clearly not executing from Windows Explorer).
Can anyone help me with this?
As theB pointed out above in a comment, this worked for me:
Open the bat file in notepad. I'll bet it starts with #echo off, and
that the error is actually coming from inside the batch file. The
error if the batch file itself wasn't found is 'X' is not recognized
as an internal or external command, operable program or batch file
'Run as Administrator' changes the current directory. See my answer here
Difference between "%~dp0" and ".\"?

Why does one code execute from one folder but not the other?

I was just curious as to why with Windows O/S a simple Ruby file that prints one line to the command prompt can execute correctly from one path, but not the other.
Currently, I have said file in C:\Ruby193\test\lib saved inside the lib folder. When I go to the command prompt and set the path to C:\Ruby193\test\lib, I'd expect to see the code string be printed to the command prompt. However, nothing but an empty line is produced, and if I go up the path and set it to C:\Ruby193\test and execute the ruby file from there, it works just fine.
Does anyone have a sound explanation as to why it works that way? Would this also be the same case for a MAC O/S as well?

Batch file is not running through Windows 7 Task Scheduler

I have a batch file that executes a php script which fetches files(pdfs) from the backend and saves locally. I have tried executing the batch file through command prompt and it works perfectly.
But when I setup a Windows Task Scheduler to run this batch, it is not working. The command prompt window pop ups and displays alot of unreadable characters and hangs there.
I have also chosen the option for the bat to run with highest privileges but no difference.
Any idea what's wrong?
My mistake. Managed to solve it. The path to php was not set properly.
Now it is fine.

Execute unicode command from script on Windows

I need to execute a command like vlc 舨.avi programatically on Windows. When done directly in cmd.exe this works just fine, proving that VLC has the capability to recognize unicode arguments. However, I'm having trouble putting this in a script and having it work.
Has anyone done this successfully? I would love to do this in Ruby (I have 1.9.2) but Python-win32, Perl-win32, batch, .cmd, VB/W/JScript are all options. Target O/Ses are XP and Vista.
It's most likely an encoding issue.
Encoding in command prompts and in windows is not always the same. If your script in Notepad, then execute it, you may end up with the filename being converted to unicode differently hence the error.
Somehow, you'll have to make sure that the encoding is correct, maybe by saving you batch file as Unicode text file? Would that work?

run windows command from bash with output to standard out?

Folks, I'm using git tools such as git bisect run which need to call a command to build and test my project. My command to do is nant which is a windows program. Or a build.cmd script which calls nant.
It's easy to get the bash to call the nant build to run.
But the hard part is how to get the standard output written to a file?
I even installed the Windows PowerShell to try running a command from bash.
Again, it works but the standard output fill says "permission denied" when
I try to read it while the build is going on.
Update:
When running nant, the entire path is used. It is installed and runs fine. The problem is how to get the standard output when running from bash.
If running nant from the windows prompt with "> build.out" at the end of the line, you will get the standard out. But the same never works under bash. It just says build.out is locked, permissions denied.
Update:
Using tee as suggested below also doesn't solve the problem. In that case the file still report "access is denied" with any attempts to read it while the build runs. But also, the tee program never writes anything to standard output.
(If I am understanding your question correctly...)
You can probably use the 'tee' command to split the output to both a file and stdout. The line echo I am building something | tee build.out will both print the output on the console and save it to the file named "build.out".
The tee command is usually available in Cygwin, and also apparently in the Bash shell installed by msysgit (where I just tested it). Here's a good reference page for more details.
Okay, finally resolved this. It turns out the the nant build script was using git feature to erase all ignored files to cleanup. That was deleting the build.out file can causing these strange issues. Now, the process writes the build.out file to a parent directory so that it won't get deleted and now everything works smoothly as expected.

Resources