3
I made a batch for windows to install some programs and make settings automatically, it worked normally, but when doing a test using a folder that had space in its name it stopped working, put in the variable "" and returned to normal.
However I want to avoid any future problem and I made a folder with some characters that can give problem, the name of the folder was this way:
New - action';#@$%&()+-.,{}][~~~~
This is my last test:
SET mypath="%~dp0"
cd %mypath%
If I opened cmd accessing the folder as administrator or with normal user works normally, but if I use the explore double click works with normal user but not as administrator, so open as administrator the script immediately closes.
My script should run as administrator so it has become a problem, of course this problem only occurs in this folder with the name full of special characters.
How to run a script without worrying about special characters?
I made a video for you to see what’s going on.
Have you thought about using the Powershell?
– Maniero
No, because I want something that the person just open and ready, I put a validation in the script, if it opens with ordinary user appears a message to run as administrator, if there is some way to run the script only with powershell for me it is okay. Because if I access using cmd as administrator I will go to the folder and run the script too.
– Wictor Chaves
I believe only if you create a real executable instead of using
.bat
.– Guilherme Nascimento
I’m researching how to make an installer, but still I wanted to know how to work with any folder using a batch, because I always have to create a batch for something, and with this answer besides helping to solve this problem since the only problem in the script is the way, it would help me a lot in future scripts.
– Wictor Chaves
I did some more tests, the content independent script (I put only the "pause" command), if it is inside the "New - action paste_action';#@$% &()+-folder. ,{}][~~~~~~" and if it runs as an administrator using windows explorer it opens nothing and closes.
– Wictor Chaves
I made a video for you to see what’s going on.
– Wictor Chaves