Batch file code to reg not working - batch-file

Hi again this has been fixed/answered just I cant answer my own question for 8 hours
... may have stuffed up a line or two with spelling mistakes..
sorry to waste anyone's time and thank you Gary for pointing out to check the reg file.
Hi everyone this is my first day... yes first day messing around with .bat files, and I have been googling the net for ages to figure this out so any help would be great.
I have been trying to get my .bat file to run a reg file from a different location, the .bat file is on the desktop. the .reg is in a folder which is located on the desktop.
what I have wrote so far is
regedit.exe /s "C:\Users\Crash Bot V1.0\Desktop\Reg Files\ChangeOpenToOpen_With.reg"
just to add, this is being done in virtual box on a windows 7 installation.
be as harsh as you feel if it is an idiots mistake, thanks again for any help.

was my path and a spelling mistake, found a neat way to avoid this issue if you know where the item is, go to it hold left shift and right click and there is a option called copy as path then when you paste you will have the path of your selected item. hope this helps someone.

Related

Batch copy files

I'm writing a batch file to perform recurring operations with choice menu options etc...
but I got stuck on two points.
I tried to read up, but I don't know exactly how to ask questions using search engines.
I try to explain myself.
Problem 1
I need to copy files to a known location, I'd like the batch to stop at some point
and asked me the default source is D:, do you want to copy from here or elsewhere? if so, insert new path
Problem 2
I'm working on Windows .wim images, the command below, as you know, is used to export a single index of these images.
When this command is executed I would like it to stop and ask me if that 4 can go well, or if not
gave me the opportunity to enter another value.
dism /Export-Image /SourceImageFile:d:\Sources\install.wim /SourceIndex:4 /DestinationImageFile:C:\test\install.wim /Compress:Max /CheckIntegrity
At the moment I have not solved the problem.

Word default folder is different when started programmatically

We have a 2 step process that collects all filenames from a folder into a Word document for use elsewhere.
The original process was to run an old DOS batchfile that collected the filenames into a DOS .txt. Then we launched a Word .docx with a macro that imported the .txt and massaged the formatting. After visual inspection we hit ‘Save’ and that was it.
I had the bright idea that a step could be taken out by launching Word directly from the batch, so I inserted the line: start winword filename. This works great except that the default location that Word wants to save in is now my Templates folder. Running it the old way still works perfectly.
The question is: why is the default location changed by launching Word programmatically and how can it be forced back to the correct location?
Thanks
you can use:
start /D C:\path\to\folder "" winword.exe
this program starts winword.exe and save all files to C:\path\to\folder
ill assume that winword.exe is in the current directory.
for help with the start command : http://ss64.com/nt/start.htm
I investigated the start command, but never did figure out why it operated differently. The eventual solution was to include the Save action in the macro. I still don't know why we didn't have to do that before, but it works now so we're declaring success and moving on.

Batch File - If File Drive Letter Equals W then

I have what I believe should be an easy answer to a question but I am having a difficult time figuring out the coding for it.
I have a batch file that runs when single or multiple files are sent through the SEND TO command when right clicking.
What I would like is if the file(s) are coming or located on a specific drive letter then it will go to a dialog and end.
I just need help figuring out the drive letter part...
if "file directory letter" = W: goto :errordialog
I have tried:
if %cd%=="W:\" goto :errordialog
if %~d1=="W:\" goto :errordialog
I have tried other codes but I think I have to do it another way?
I know I have to be making this too hard right?
Well what seemed to work is :
[%~d1]==[W:]
Late answer, but this is safer:
if "%~d1"=="W:"
The quotes(") makes the string as one piece. So this wouldn't happen:
if [ ]==[W:]
Although this shouldn't happen when %1 is a path, just a pre-caution.

Batch: Relative directory/path

I created a small harmless batch virus (a prank), it is finished (on a USB) but I don't want to manually copy it and then I ran to a problem...
Is there a way to copy files relatively, from where the actual batch file is?
Something like this maybe:
copy "~Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"
instead of
copy "G:\Files\Folder1\Folder2\Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"
If somebody can help please do... Thanks!
This question may solve your problem, but a short answer for copying your file is using %~dp0. As said in this answer, this will give you the current path.
Try this:
copy "%~dp0Virus.bat" "%appdata%/microsoft/windows/start menu/programs/startup"

open chromium portable .bat file

I've written a .bat file to open chromium portable in to kiosk mode on the page I want like a full screen app. This works great. My problem is it doesn't work if it's in a folder with spaces in. I know I probably need to add quotes somehow but not sure how to do it using the %cd% command can anyone tell me how to make my .bat file work from any folder? The code is below:
#echo off
start %cd%\appdata\chromeportable.exe --kiosk %cd%\appdata\app.html
How can i edit it so that it will run from folders with spaces in the title!
I don't quite follow your question, but here are a few things to try
To change directory to a path with spaces use
cd "C:\folder\folder with spaces"
To start the batch file from a folder with spaces from another directory
"C:\folder\folder with spaces\openchromium.bat"
If this isn't what you are trying to do please improve your question.
Update
After posting your code I can see a possible issue. When you use start and the path in the first argument is quoted it will treat it as the title, to fix this you give it a blank title like this
start "" "%cd%\appdata\chromeportable.exe" "--kiosk %cd%\appdata\app.html"
Hope this helps

Resources