Running several .bat files within command prompt - batch-file

I am trying to start the wso2 iot server with the command prompt, to do that i have to execute three .bat files which have the same name and are in different folders, is it possible to start them all in the same command prompt ? and if not how can i execute them in an alternative way ? thanks in advance!

You need to specify the absolute filename of each. OR you could change directory to each and run the batch name.
pushd/popd changes to the directory and back if you don't want to cd.
Remeber to "quote the fullpathtobatchname" if it contains spaces. If you are using start then remember to include a windowtitle as the first quoted parameter if using quoted arguments.

You can do it, only need chance the offsetvalue in your [ESB_HOME]\repository\conf\carbon.xmlto 2 servers so that they are not exposed by the same port. regards

I also have the same problem, when i try to run the second bat I get a pile of errors, and i can no longer access carbon home through the web browser
C:\wso2\wso2esb-5.0.0\tmp\AXIS2-~1.TMP\axis22597661185720064274rampart-1.6.1-wso2v18.mar - The process cannot access the file because it is being used by another process.
C:\wso2\wso2esb-5.0.0\tmp\AXIS2-~1.TMP\axis2545956122453586080addressing-1.6.1-wso2v19.mar - The process cannot access the file because it is being used by another process.
C:\wso2\wso2esb-5.0.0\tmp\javasysmon64130642671302902180.dll - Access is denied.
C:\wso2\wso2esb-5.0.0\tmp\javasysmon65576392292672845032.dll - Access is denied.

Related

Access denied when renaming folder with cmd [duplicate]

I don't know if this is the right place to ask this question, but I am going to ask it anyway.
I have a frequent problem when I try to rename one of my folders; it says access is denied. I have full administrative rights on my computer. The problem occurs only when I try to do it via command prompt or batch files. I can manually rename the folder with no problems whatsoever. But I need to be able to rename it using the ren command. It is an irritating problem, and I have heard other people having the same problems. They usually fix it by re-taking ownership of the folder and restarting the computer. This works for me, but I hate having to do this every time. Is there a permanent solution that I can do to stop this problem? Also, when this problem occurs, it happens to all folders; I can't rename any of them using the ren command.
The answer is quite simple:
Windows does not permit deletion or renaming a directory/folder which is
the current directory of any running process (application/service) like the command process, or
any subdirectory of the directory to rename is the current directory of any running process, or
any file is opened in the directory to rename or any of its subdirectories by any process with OF_SHARE_DENY_READ, OF_SHARE_DENY_WRITE, OF_SHARE_EXCLUSIVE used on opening the file.
In other words as long as the directory itself or any file or subdirectory in this directory or its subdirectories is in use by any application, Windows denies renaming or deleting the directory.
On Unix/Linux it is possible to delete or rename a directory while it is in use by 1 or more running processes. The running *nix process has to handle the special use case that the directory or file just accessed successfully a millisecond before does suddenly not exist anymore.
My approach to solving this problem is to run the utility Handle, by Mark Russinovich of Windows Sysinternals. You can find it here.
This utility will show all the open handles on the system and which process is using them. One of them may have a path to the folder you are trying to rename.
I typically redirect the output of handle.exe to a file.
handle >handles.txt
Then I look at handles.txt in a text editor and search for the name of the folder I was trying to rename. It will appear in a section of handles belonging to the process that is keeping the handle to that folder open, and hence preventing it from being renamed. It shows the pid of the offending process, which you can decide how to deal with, in case you need to terminate it.
e.g. Trying to rename myfolder I forgot I had started a service running using pm2 (a process monitor) The output of Handle.exe included the following:
node.exe pid: 12752 DISCO\Stu
40: File (---) C:\Dev\myfolder\service
I fixed this by disabling Quick Access:
See Screenshot:
[
Well before you can run this command you have to have the privileges to do so as overwriting or modifying files from the command line requires admin rights. Once you got that done, enter the following:
ren (path name) (modified name, no quotation marks)
1 copy path of the folder. To do this, hold shift and right-click, you'll see the "copy as path option"
2 open cmd as admin. To do this, press window + X, then A.
3 in the cmd, type "cd C: then paste the path" so it will be, for example, like:
cd C:\Users\abc\Desktop\music
before you press enter, quote the last name; for example:
cd C:\Users\abc\Desktop\"music"
4 Next, type: ren *.present extension *.new extension; For example, from mp3 to exe:
ren *.mp3 *.exe
If no extension was existing, then, for example:
ren *. *.exe
This should work and eliminate the access denied nuisance.
I solved this problem by giving the user who run the batch full right on the directory. It seems the right from a group membership is not sufficient: the user was member of the local group Administrators and I received a "Access denied". After having added the user account in the directory security with full rights, it does the job.

Access is Denied When Renaming Folder

I don't know if this is the right place to ask this question, but I am going to ask it anyway.
I have a frequent problem when I try to rename one of my folders; it says access is denied. I have full administrative rights on my computer. The problem occurs only when I try to do it via command prompt or batch files. I can manually rename the folder with no problems whatsoever. But I need to be able to rename it using the ren command. It is an irritating problem, and I have heard other people having the same problems. They usually fix it by re-taking ownership of the folder and restarting the computer. This works for me, but I hate having to do this every time. Is there a permanent solution that I can do to stop this problem? Also, when this problem occurs, it happens to all folders; I can't rename any of them using the ren command.
The answer is quite simple:
Windows does not permit deletion or renaming a directory/folder which is
the current directory of any running process (application/service) like the command process, or
any subdirectory of the directory to rename is the current directory of any running process, or
any file is opened in the directory to rename or any of its subdirectories by any process with OF_SHARE_DENY_READ, OF_SHARE_DENY_WRITE, OF_SHARE_EXCLUSIVE used on opening the file.
In other words as long as the directory itself or any file or subdirectory in this directory or its subdirectories is in use by any application, Windows denies renaming or deleting the directory.
On Unix/Linux it is possible to delete or rename a directory while it is in use by 1 or more running processes. The running *nix process has to handle the special use case that the directory or file just accessed successfully a millisecond before does suddenly not exist anymore.
My approach to solving this problem is to run the utility Handle, by Mark Russinovich of Windows Sysinternals. You can find it here.
This utility will show all the open handles on the system and which process is using them. One of them may have a path to the folder you are trying to rename.
I typically redirect the output of handle.exe to a file.
handle >handles.txt
Then I look at handles.txt in a text editor and search for the name of the folder I was trying to rename. It will appear in a section of handles belonging to the process that is keeping the handle to that folder open, and hence preventing it from being renamed. It shows the pid of the offending process, which you can decide how to deal with, in case you need to terminate it.
e.g. Trying to rename myfolder I forgot I had started a service running using pm2 (a process monitor) The output of Handle.exe included the following:
node.exe pid: 12752 DISCO\Stu
40: File (---) C:\Dev\myfolder\service
I fixed this by disabling Quick Access:
See Screenshot:
[
Well before you can run this command you have to have the privileges to do so as overwriting or modifying files from the command line requires admin rights. Once you got that done, enter the following:
ren (path name) (modified name, no quotation marks)
1 copy path of the folder. To do this, hold shift and right-click, you'll see the "copy as path option"
2 open cmd as admin. To do this, press window + X, then A.
3 in the cmd, type "cd C: then paste the path" so it will be, for example, like:
cd C:\Users\abc\Desktop\music
before you press enter, quote the last name; for example:
cd C:\Users\abc\Desktop\"music"
4 Next, type: ren *.present extension *.new extension; For example, from mp3 to exe:
ren *.mp3 *.exe
If no extension was existing, then, for example:
ren *. *.exe
This should work and eliminate the access denied nuisance.
I solved this problem by giving the user who run the batch full right on the directory. It seems the right from a group membership is not sufficient: the user was member of the local group Administrators and I received a "Access denied". After having added the user account in the directory security with full rights, it does the job.

run cygwin command through batch file

I am running a rsync ssh command in cygwin in windows. Upon this, password is asked and if given, it does the intended task. Now I want to put these all tasks in one batch file, which can be run on one click.
Thanks
Step 1: Set up an authorized_keys file on the server so that you can ssh in from your local machine without using a password (check the security implications of this carefully). You can find instructions for this in many places, including the official documentation.
Step 2: Add Cygwin's bin directory to your Windows PATH environment variable. If you don't want to do it permanently, you could write that into your batch file.
Step 3: Write your one-line batch file using the exact same rsync command line you used in Cygwin. Pathnames should not need translating unless you expect the shell to expand a wild card. If you use any sort of quoting then that might need adjusting.
Step 4: Configure Windows to run programs with one click, instead of double click. Not sure how you do that; I don't use Windows much.

Batch file not working when running in the background - issue with substituted drive

I'll try to keep this short, without all the details of this batch file procedure.
OS: Windows XP
Action: Scheduled Task (background, I can't find a way to run it in the foreground)
Problem: files not created on mapped drive. When the batch file is ran directly, it works.
It does the following (or at least tries to):
clean a directory: works
create executables based on a substituted location
We use the following to map a local folder to the K: drive:
subst K: /D
subst K: D:\Development\SVN
The executables are built from source code that is located on (for example) K:\Sources to K:\Executables.
This fails, for a reason I did not yet discover. As mentioned above, if the batch file is ran directly it doesn't fail. If I substitute K:\ by C:\Development\SVN the issues seem to be resolved but still, this doesn't solve the fact that I can't run it when using K:.
I hope anyone here has an idea, I tried Googling for a long time + scanning SO but to no avail.
Thanks in advance!
substed drives are local to session, and your scheduled task is run in another session then your login session.
It seems to be possible to schedule task for user login session with schtasks.exe command line, but then the task runs only if the user is logged in. It might not be what you want, so using a full non-substed path might be the best solution after all.

Updating SVN remotely via batch file

I tried searching relevant threads, it didn't worked. So here are the detailed question / situation, where I am looking for help.
I have 30 client nodes where I have setup SVN and checked out two folders (which needs to be updated) exactly when I want (forcefully).. e.g : "d:\gbv\textures" and "d:\gbv\characters"
then I put svnUpdate.bat file in main d: drive with relevant command e.g: "svn update blabla"
if I run this bat file by double clicking, it works fine ( it updates )
now I thought, I should create a batch file, where I type all 30 nodes IP, and set of commands, to run that batch file from local d: and it should work.
PROBLEM: I am unable to do this.
because I am unable to do this, from my cmd panel.
because I am not sure, how I can access network pc and tell it to run "d:\svnUpdate.bat" from its drive from dos prompt. ( obviously, I can do this via win explorer visually ).
Hopefully the question will make sense.
You can execute files on remote machines in a network using PsExec. I use it to execute batch files and pass parameters to them.
You'll probably need the -w option to set the working directory.
Of course this is a lot easier with powershell remoting, but since you already set it up with batch, PsExec works fine.

Resources