Call .bat file from anywhere in the directory using python - file

I need to call a .bat file from anywhere in the directory without including the specific directory in the script. You'll just need to specify the name of .bat file you want to call and then run. Is this possible?

Add the .bat file's directory into your PATH.
This is an article for you.
http://www.computerhope.com/issues/ch000549.htm

do you mean calling a script without specifying the exact location from commandline?
there are two ways:
add it to your path (eg: set it in your PATH environment variable)
setup an alias/some sort of shortcut in your bashrc/whatever CLI you are using (since you are using windows, one example would be to setup a cmdlet in windows powershell or something)

Related

Windows environment variable %USERPROFILE% in File URI Scheme (three slashes)

In Notepad++ I have a link to a batch file using a "File URI Scheme with three slashes" convention as follows:
file:///C:/Users/john.doe/some_folder/test%20file.bat
When I double-click on it, the link works (i.e. the double-click runs the batch file).
I want to modify the File URI to incorporate %USERPROFILE% like so:
file:///%USERPROFILE%/some_folder/test%20file.bat
This doesn't work. Is there some character I can add or remove or escape to make it work?
UPDATE: since making this post, I've learned that Notepad++ doesn't expand Windows environment variables.

Running several .bat files within command prompt

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.

Using Lua How to read or write in different directory?

I am able to create write read and append in same directory using Lua. Now I want to write to a sub directory. Can someone please show? Thx.
I.e. Existing Current dir: C:\main
Existing subdirectory: C:\main\sub
New file: C:\main\sub\newfile.txt
Writing into a sub-directory is no different from writing into a file in the same directory. The only issue you may run into is with escaping Windows path separators, so instead of "C:\main", use [[C:\main]] or "C:\\main".
If the folder needs to be created, you'll need to use shell commands or lfs library as the default Lua interpreter doesn't provide API to create folders.

I want to create .exe file to create multiple folder at a same time

I want to create .exe setup or batch file to create Multiple folders at same time.
and folder name prompt to give or take from .txt file.
If you are ok to enter the name of the folder each time, you can simply use the md command of the Windows Command Line!
Syntax: md MyFolderName
Your question is Operating system dependent.
To create an executable
In windows you can use Visual Studio console application to create a c++ code and build it to obtain a .exe file. You have to take care on the linking options.
To create a directory simply do mkdir("foldername") and to read or write from txt file, create a file stream and use getline to read the names of folder.
In linux I suppose it can be done by writing a bash script.

pass execution path of sfx to batch file

So basically i want to wrap my batch file in an sfx to make a tidy package as I am using multiple files that need to be packaged with the batch file. The problem I am facing is that I need drag and drop functionality so I need to somehow pass the file dropped on the sfxz to the batch file via the execution code.
I am using the winrar default sfx module.
So far I have tried passing it with the %~1 variable but that just passes literally %~1 instead of the location of the dropped file
Any help will be appreciated.
You can use BHX from here to encode the binaries into the batch file, so it is just one file to distribute. http://www.dostips.com/forum/viewtopic.php?f=3&t=4104

Resources