open chromium portable .bat file - batch-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

Related

How to Open Files in Directories with Spaces using CMD as Admin?

I'm writing a script to automate software installation and optimization using batch files. It needs administrator privileges.
When admin rights are given to cmd, I had to switch from "%cd%\program.exe" to "%0\..\program.exe". However, after doing that, I can't get a file to open if it is in a directory with spaces.
Subsequently, I removed the quotation marks at the beginning like this:
%0\..\program.exe"
This caused the directory problem to go away but now Programs with spaces won't open and using xcopy will give me a parse error.
I need it to open both files with spaces and files inside of directories with spaces.
Please help me solve this problem. Thanks in advance.
%0 should already be doublequoted, but is the drive path name and extension of the running batch-file. You really want to use this:
"%~dp0…\program.exe"
… represents an actual directory sequence, not a relative path
To get a better idea of what is going on open a Command Prompt window, enter Call /? and read its output.
Note: the p in %~dp0 already has a trailing backslash, so you don't need to append one yourself.

Trying to copy a file to the windows autoexec folder in a batch file

im trying to copy a file to
c:\users\%username%\%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
so far i have tried:
echo . > test.txt
move test.txt c:\users\%username%\%AppData%\Roaming\Microsoft\Windows\StartMenu\Programs\Startup
with
The file, directory or volume's syntax is incorrect.
(Had to translate this bit so it might not say the same exact thing on your pc.)
as a result.
I am a beginner at this and im self-teaching this language so please forgive me if i make silly mistakes that can be easily corrected without noticing it.
Do some debugging and you'll see why it's going wrong. In a Command Prompt window, type:
echo %AppData%
You'll see that this environment variable contains everything you need from the drive letter all the way to "Roaming".
So you need:
move test.txt "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup"
The quotes around the second parameter are required because the "Start Menu" directory contains a space in its name.

Batch Script doesn't copy to Autostart

My batch should solve a issue, but it doesn't quite work. I think it's simple, i just don't see it. I know it needs Admin, but i shortend the code to where the problem actually is.
copy "Data\invisble.vbs" "%appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
cd "%appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
start invisble.vbs
cls
Without seeing the rest of the code it's hard to know the context.
Please note that the %appdata% environment variable changes for each user.
Also note that copy "Data\invisble.vbs" specifies a relative path.
The easiest way to pinpoint the issue is to open up a command prompt and run each line and verify the results.

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.

"start" command in .bat batch file

I have an extremely simply batch file, which has previously worked for me but no longer will.
start /wait steamcmd +login anonymous +force_install_dir C:\Games\CSGOServer\TEST
pause
For some reason I get the following error upon running the file:
http://imgur.com/Xd8di1Y (sorry, not enough rep to enbed with html)
Any ideas why start will not work given that it is clearly an accepted command? I did notice the strange characters in front of this but cannot really tell where these would come from.
Thanks in advance.
Damon
Looks like someone saved that batch file in UTF-8 format. Open the file with Notepad and click File → Save As.... Change the field Encoding to "ANSI" and click Save. Confirm that you want to replace the file.

Resources