CMD script not running in the root path of the file - batch-file

I created a Windows Command Script, .cmd, to perfom a list of project tasks. This batch file is placed in the root folder of the project, so when I run it, double clicking the .cmd file, it starts the script placed where the file is located, e.g. C:\user\project\TheProject.
The problem comes when I send this file to another machine, first it is recognized as an unknown script, so the end user has to agree to 'run it anyway'.
After that doesn't matter where the file is placed, it always start in the same route C:\Windows.

Related

Run multiple lines from .bat file

I'm trying to get a bat file together and not sure how to run multiple cmd lines through the .bat.
Objective: I want to be able to click on this .bat file to open cmd prompt, then to find a "folder" in the directory, rename the "Folder" then move the location of the folder then find a existing Folder and put it in the same directory.
Problem: i know how to run these cmds in the prompt without an issues.
So far this is what i have:
#echo off
start cmd.exe /k cd %AppData%\Microsoft\Network\Connections
#echo off
and then just write your commands its that simple
A .bat file is executed in a terminal window automatically, you don't need to call cmd.exe or anything like that.
Every single line you write in the .bat file is going to be executed one by one, so you just need to write multiple lines with all the instructions and then you can double click on your new file to run the script.
If you are not familiar with Windows commands for the terminal, you can find more info on the web about how to find a folder, rename it, etc. There are many things you can do by command line and this is not the right place to explain how to use them.

Batch file works when run from command prompt, but not when clicked on

I have a simple one-line batch script to map a network drive drive. I'd like to place this in the startup folder so that I have the drive available whenever I turn my computer on.
The file looks like this:
#echo off
pushd \\path.to.network\drive
When I open up command prompt and run map_drive.bat, it works as intended and I am now able to access my drive. However, when I double click on the file or place it in the startup folder and turn my machine on, nothing happens.
]I've tried running as an administrator, putting the network path in quotes, and adding a "pushd %~dp0" line to the start of the file, but none of these so far have made a difference.

Include file in console application

similar to this -> Create a standalone .exe file
however I am not sure about the responses posted there.
I have a console application and i want to launch and execute a batch file.
build everything works fine, but when i move the compiled .exe file, it says file not found.
How do I ship test.bat with my .exe, I do not want to create an installer, rather a standalone exe. Not comfortable with ClickOnce.
Update Currently I add that batch file as a resource, read its contents and re-create the file in a temp location. Then execute that batch file from there. Any other suggestions ?

.bat start command opening .exe but not loading info file

i am trying to start up a series of .exe's (minecraft console client)
with only 1 click but when i setup an .bat file it opens it in the folder where the .bat is placed not where the .exe is and all the info files are where the .exe is, i would just move them but all the info files are called the same things with diffrent info and the .exe is encrypted (so nobody can take code, i think its called encrypted idk).
How I want it to load: http://gyazo.com/a451735cb34262bf1bfc0709e7d6a11c
How it actually loads: http://gyazo.com/4ed35f560c41370d9d33f865fc67fccf
The .bat: START C:\Users\Fergal\Desktop\ConsoleClient\Vortex\Pinshi_Bwub\MinecraftClient.exe -Would have used another gyazo but don't have enough rep :(
Try the following batch file:
cd C:\Users\Fergal\Desktop\ConsoleClient\Vortex\Pinshi_Bwub
start MinecraftClient.exe

How to customize shortcut in compressed file to run exe from current directory?

How to customize shortcut in compressed file to run exe from current directory? For example, i want to put compress two file inside winrar first is program.exe and the second is shortcut to that program, if i compress that in rar extension, and copy compressed file in other directory and open with winrar and run shortcut, i get nothing. So my question is what code to put in shortcut to run program.exe regardless in which directory will be compressed file extract?
You get nothing because there is no program to run. A compressed file isn't a filestore from which files can be run. When you "run" a file from a compressed file, the OS is actually extracting that file to a temp folder and then running it. When you tru and run the shortcut, its being extracted, but the temp folder in which it was extracted doesn't contain the actual .exe you're trying to launch, so nothing happens.
As to how you achieve what you want, I have no idea, but would not be suprised if it was not possible. If you're running the exe from a compressed file, why do you need the shortcut? Why not just click the .exe?

Resources