I am trying to map a drive using a batch file.
I have tried:
net use m: \\Server01\myfolder /USER:mynetwork\Administrator "Mypassword" /persistent:yes
It works fine. The problem comes when I try to map a folder with spaces on its name:
net use m: \\Server01\my folder /USER:mynetwork\Administrator "Mypassword" /persistent:yes
I have tried using quotes, using myfold~1 but nothing works.
An easy way would be renaming the folder but I have it mapped in more than 300 workstations so is not a very good idea.
I just created some directories, shared them and mapped using:
net use y: "\\mycomputername\folder with spaces"
So this solution gets "works on my machine" certificate. What error code do you get?
whenever you deal with spaces in filenames, use quotes
net use "m:\Server01\my folder" /USER:mynetwork\Administrator "Mypassword" /persistent:yes
I'm not sure this will help you to much by I once needed a batch file to open a game, the .exe was in a folder with blanks (duh!) and I tried : START "C:\Fold 1\fold 2\game.exe" and START C:\Fold 1\fold 2\game.exe - None worked, then I tried
START C:\"Fold 1"\"fold 2"\game.exe and it worked
Hope it helps :)
net use "m:\Server01\my folder" /USER:mynetwork\Administrator "Mypassword" /persistent:yes
does not work?
net use f: \\\VFServer"\HQ Publications" /persistent:yes
Note that the first quotation mark goes before the leading \ and the second goes after the end of the folder name.
Related
i want to create a portable roblox but these bothers me
i am not so good at batch file but how to i run these exe under these directory i mean
if roblox has an update the "version-3bxxxxxxxx" will change and i cannot run the exe anymore
start "" "C:\Program Files (x86)\Roblox\Versions\version-3b33190189084158\RobloxPlayerLauncher.exe" -app
start "" "C:\Program Files (x86)\Roblox\Versions\version-3b33190189084158\RobloxPlayerLauncher.exe" -app
i try to search on the internet give nothing more =(
I hope you found the help you needed by now, sad no one responded after all this time. This is not as elegant, but I had the same issue and I did this as my solution:
cd\Progra~2\Roblox\Versions\version-* <-just need a "*" wildcard there
start RobloxPlayerLauncher.exe -app
Hope this helps others that want to run a batch file for programs like Discord and Roblox etc. as their directory names always change with updates.... The practice is annoying and I wish devs would consider end users setups.
rEd2k's answer is fine for use directly on the command line. With a batch script, you can automate it.
Search for the exact folder name with a for /d loop and use the found folder as working folder with the start command:
for /d %%a in ("C:\Program Files (x86)\Roblox\Versions\version-*") do set "rootdir=%%a"
start /d "%rootdir%" RobloxPlayerLauncher.exe -app
NOTE: if there is more than one matching folder (versions), rootdir will contain the last found folder (by string sorting on NTFS), which is probably good enough.
I'm trying to send network credentials using Net Use command.
This is what I have:
#echo off
net use \\<serverName>\<shareFolder>\ passw0rd /USER:domain.com\UserName
PAUSE
This automatically inserts the username and Domain but for some reason not the password!!
I have tried it like this as well:
#echo off
net use \\<serverName>\<shareFolder>\ /USER:domain.com\UserName passw0rd
PAUSE
I have checked the paths I'm using and they definitely work. When i copy them out and paste in RUN they work.
Same goes for the username and passwords.
Everything in google search is purple cause I've clicked on all the links :/
Ok, I thought I had it...
I tried it like this:
#echo off
net use \\<serverName>\<shareFolder>\ <mapName> /USER:domain.com\UserName passw0rd
PAUSE
And it worked, but only because i entered the password before i tried it like this and then it remembered the password.
So I'm still looking for a way.
Please help.
Does the password contain special characters like % / ~ or similar characters with special meaning in batch files?
Yes, then enclose the password in double quotes.
Use also double quotes around UNC path and test if that makes a difference.
What I miss in all your net use commands is the device name usually specified left of UNC path to shared folder to map the shared folder to a drive letter. Therefore it could be that the password is interpreted as device name.
But according to your question you want to pass only the user credentials and password to be able to access the shared folder using UNC path. However, I suggest to test if it makes a difference really mapping the shared folder to a drive letter. I don't know if the password string is interpreted as device name if no device name specified and can't test it by myself at the moment.
#echo off
net use <MapDriveName> \\<serverName>\<ShareFolder>\ /PASSWORD:<Passw0rd> /USER:<UserName>
PAUSE
This one works for me. Finally :)
Hope this can help someone else as well.
net use Y: \server_name OR ipaddress\shared /user:domainname\%username%
I am putting Kingsoft office on my flash drive, and I want to use a batch file to start the applications because the paths are not easily accessible, I cannon create a .lnk file because the path varies by computer because it may be plugged into a different port. Here is my batch file code, could somebody give some suggestions on how to make this work. Thanks in advance...
set "path=%~dp0"
start %path%office6\wpp.exe
The second line is the problem, the program won't start the program. Thanks!
cd /d "%~dp0"
start "" /b wpp.exe
I think some of the directory names in %path% contain spaces and since %path% is not enclosed within ""( double quotes), the script is unable to find the exe .
You may also want to include a log file so that it becomes easier to debug in case of any errors.
Try this:
set baseFolder=%~dp0
start "%baseFolder%office6\wpp.exe" > "%baseFolder%batchRunLog.log"
I have a batch script that checks to see if a directory exists then maps it, if it does exist.
if exist \\server\folder1\%username% net use g: \\server\folder1\%username%
Lately the script hasn't been mapping correctly with some computers, on those computers in needs to be change to
if exist \\server\folder1\%username%\ net use g: \\server\folder1\%username%
Why would that backslash make a difference? Isn't it pointing to the same directory? Why would "if exist" need it and "net use" not need it? Users do NOT have access to folder1.
Now, I came across an older version of the same file written by a previous employee and he wrote it as
net use g: \\\\server\folder1\%USERNAME%
Why would he put four slashes?
I'm not sure if this is your problem, but if exist \\server\folder1\%username% is TRUE if %username% is a valid file or folder within folder1.
Adding a backslash at the end forces the condition to only be true if a folder exists.
I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application.
I do this by using a If Not Exist filename statement. If the installed file doesn't exist, I then execute the installation file.
For some reason, when I test it with the application where it has been installed already, it is still trying to reinstall the application over it.
Here is a snippet of my code:
cd "C:\Documents and Settings\John\Start Menu\Programs\"
pause
If NOT exist "Software Folder"\ (
start \\filer\repo\lab\"software"\"myapp"\setup.exe
pause
)
Where SoftwareFolder is a subdirectory of "C:\Documents and Settings\John\Start Menu\Programs\". I am checking to see if it exists in my Programs folder.
I know nothing is wrong with my start command. I have a feeling something is wrong with my beginning CD command or one of its parameters.
Thanks a lot, guys!
Use the FULL path to the folder in your If Not Exist code. Then you won't even have to CD anymore:
If Not Exist "C:\Documents and Settings\John\Start Menu\Programs\SoftWareFolder\"
I noticed some issues with this that might be useful for someone just starting, or a somewhat inexperienced user, to know. First...
CD /D "C:\Documents and Settings\%username%\Start Menu\Programs\"
two things one is that a /D after the CD may prove to be useful in making sure the directory is changed but it's not really necessary, second, if you are going to pass this from user to user you have to add, instead of your name, the code %username%, this makes the code usable on any computer, as long as they have your setup.exe file in the same location as you do on your computer. of course making sure of that is more difficult.
also...
start \\filer\repo\lab\"software"\"myapp"\setup.exe
the start code here, can be set up like that, but the correct syntax is
start "\\filter\repo\lab\software\myapp\" setup.exe
This will run: setup.exe, located in: \filter\repo\lab...etc.\
As in the answer of Escobar Ceaser, I suggest to use quotes arround the whole path. It's the common way to wrap the whole path in "", not only separate directory names within the path.
I had a similar issue that it didn't work for me. But it was no option to use "" within the path for separate directory names because the path contained environment variables, which theirself cover more than one directory hierarchies. The conclusion was that I missed the space between the closing " and the (
The correct version, with the space before the bracket, would be
If NOT exist "C:\Documents and Settings\John\Start Menu\Programs\Software Folder" (
start "\\filer\repo\lab\software\myapp\setup.exe"
pause
)