I want to make a .bat file that runs these lines of code but I can’t figure that out
bcdedit -set TESTSIGNING OFF
shutdown -r
Create a text file
rename the file to Example.bat
edit the file and place your code
Save the file and then run it
Congratulations, I have become a programmer😂
Related
I am trying to open a .chm file from a batch file.
The batch file has only this text in it :
echo off
start "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
If I run the batch file, the commandline opens but nothing further happens.
If I copy paste S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm in start menu/run then it does works.
If I make a shortcut with target "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm" then it also works.
So the command works everywhere, except from a batch file.
What am I doing wrong here ?
It might also be important to know that when I start it from the shortcut, or start menu/runI always get a dialog
We can't verify who created this file. Are you sure you want to open this file ?
I am using Windows 7
EDIT
My problem is not the dialog, my problem is that nothing happens when I open the chm file from a batch file
The Start command is probably seeing your doublequoted string as a title, enter Start /? at the command prompt for its usage information.
Try adding an empty title first:
#Echo Off
Start "" "S:\G.T.T\GTT-Vandemecum\Help Danny\GTT.chm"
I need save the output to devcon in a .txt, if I use the command lines I don't have a problem but I when use a batch file, this create the file but the file is empty.
This is the command line in my batch file:
devcon.exe status * > file.txt
A test here (windows 8.1) shows me that devcon outputs to a different console screen if you don't run as administrator.
So right click the batch file and run it as administrator.
I'm trying to create a bat file to copy a dll to paste in the windows foler, the file already exists in windows but I want to print my own.
The code I have is:
DIR \Windows\shdoclc.dll
icacls \Windows\shdoclc.dll
ATTRIB -R -S -H \Windows\shdoclc.dll
COPY \Temp\shdoclc.dll \Windows\shdoclc.dll
pause
I can copy/paste it manually from windows ce, everywan, or activesync, but the command terminal doesn't work because of the file location, the file is hidden/ read only/ and a system file, the attribute command doesn't work.
and it gives me an error every time the \windows\shdolc.dll is involved, but if I change the file name or location the copy works fine.
I think it's a problem with the permision of the command prompt, don't nkow how to change it though.
Windows has that file as a protected file, so will restore it whenever it is changed.
Here's a cheat to get around that (unfortunately, I don't have ce to test, only XP)
COPY \Temp\shdoclc.dll %systemroot%\system32\dllcache
DEL %systemroot%\shdoclc.dll
This copies your version into the cache, and when the actual file is deleted, windows restores the version it has backed up in the dllcache.
for some reason, the copy command doesn't let you copy over a system file. the attribute command doesn't let you change system file attribute, but the move command lets you replace a system file, so my code ends up being:
copy \Application\shdoclc.dll \Temp\shdoclc.dll
MOVE \Temp\shdoclc.dll \Windows\shdoclc.dll
Newbie to windows scripting. I need help running the .bat file on the command line so I can test it.
I used Text Document as my editor to create the file (opens up also as Notepad).
I performed file "save as" (ALL FILES). If I open up cmd, I can see the file has a .txt extension (myfile.bat.txt). So if I just type in cmd myfile.bat.txt the editor opens. I am not sure how to execute this correctly.
As for the logic in my batch script, I am basically logging into a remote directory (already created the net mount) and now I want to:
run an executeable file
rename some files.
With some research, I written this so far. I have saved it as a .bat file
# echo off
echo This is a batch file to run an executable and rename some files
pause
--run executable file here, just don't know how to do it
x:
cd x:
rename fileA fileB
Any help, good tips/practice would be great. Thanks.
Type in this command in cmd window:
rename myfile.bat.txt myfile.bat
Now you can run the script by simply invoking:
myfile.bat
or
myfile
(provided there's no myfile.exe or myfile.com in the same directory).
If you need to edit the script further, you can either right click it in Explorer and choose Edit or call the editor from the command window:
notepad myfile.bat
To call a program from the script, simply add its name, if it's in the current directory:
someprogram.exe
or the name with the path, if it's somewhere else:
directory\program.exe
or
d:\directory\program.exe
If the name or the path contain spaces, be sure to enclose the entire name & path string in double quotes:
"d:\directory\program name.exe"
you can just type the full name of the program
eg
"c:\program dir\program.exe"
or you can add the program directory to your path environment variable
set PATH=%PATH%;"c:\program dir"
and just type the program name
program
you can also edit your PATH variable in windows http://support.microsoft.com/kb/310519
NOTE: When you save the file in notepad, you want to save it as filename.BAT and select All Files from the second dropdown. If you don't it still gets saved as a .TXT.
A couple of command to consider:
CSCRIPT cscript /? in CMD
START http://ss64.com/nt/start.html
If you're doing say a VBSCRIPT use CSCRIPT to start it. If you're trying to execute another BATCH script or an EXE, use START
My program needs .bat file to run because the .bat file is changing some language settings, so .bat file looks like:
set lang=en
start ap.exe
It is working great but when I made installer for my app and pointed .bat file as main file, it creates a shortcut on the desktop to that .bat file. So far everything is great but when I launch that shortcut it cannot open app.exe because it can't find it on desktop.
So my question is: How can I get path to folder of .bat file so I could set proper start command? Something like:
set lang=en
S=getpath();
start S/app.exe
It is just pseudocode but I think you get point.
You can write %~dp0 to get the directory containing the batch file.
Therefore, you can write
"%~dp0app.exe"