How to change the path of a mapped drive in win7? - windows-7

Now it's mapped to \\192.168.248.128,how to change it to \\192.168.66.2 instead?

If you want to use the command line have a look to the next answer below!
But you can also edit the settings in Windows Registry: 'HKEY_CURRENT_USER\Network\[Drive letter]'
When you now open a new 'My Computer' window - after changing the target in registry - you will likely see the old settings, but that is only a visual problem. Try to open the entry, and it should work!
Have a look to Chris Budys interesting comment below, that fixes obviously the visual problem.

net use can modify a drive in place without deleting and recreating. You simply execute the command as if you're mapping a new drive, and it replaces it instead. The command syntax is:
net use [Drive name] [UNC path]
Example:
C:\> net use U: \\192.168.66.2
U: has a remembered connection to \\192.168.248.128. Do you
want to overwrite the remembered connection? (Y/N) [Y]: y
The command completed successfully.

You can create another mapped network drive:
right-click the current drive and click "Disconnect"
right-click "Computer" and select Map Network Drive
configure the new drive
If you want Windows API you can use WNetAddConnection2.
If you want a BAT (command line) you can try net use command line option.

Related

Can't run batch file as Administrator on subst drive

On Windows 10.
Steps to reproduce problem.
1) Use subst from command line to setup a drive letter. e.g.: subst v: c:\temp
2) Create a batch file c:\temp\hello.bat:
echo hello
pause
3) in windows explorer, go to v: drive.
Try to run hello.bat by right clicking, and selecting Run As Administrator.
The expected Windows security question "Do you want to allow this app to make changes to your device?" comes up. When you answer Yes, nothing seems to happen.
I know I can go to c:\temp in Windows Explorer, and this will work, but it's not ideal.
I gather it is something to do with Run As Administrator context not being able to see the subst drive?
Are there any workarounds, to be able to get this to work? So that batch files can be run in Windows Explorer on the subst drive as Administrator.
EDIT:
A workaround of sorts:
In Windows Explorer, go to c: drive. Then c:\temp. Create a shortcut to hello.bat. Also tick the Run as Administrator option.
In Windows Explorer, go back to v: drive. Double click the shortcut to run hello.bat as administrator. This seems to work.
Mods: feel free to move this question to Superuser, if it turns out there is nothing you can do in the batch file itself to make this work.

The System cannot find the file specified error while deleting folder

Hi can some one suggest me how to delete below folder(abc) using a batch file?
%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc
I tried like RD %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc /Q /S
But it is not deleting and when I execute the same command in command line it is giving a message like "The System cannot find the file specified" even though it is exists.
Any solution?
I used "rm -rf PATH_TO_FOLDER" command line on Git Bash (not cmd), then I can delete the similar folder.
Note: Tested on Windows 10 (latest version).
Use 7-zip to "move" them.
When facing an inability to delete a file because of "the system cannot find the file specified" I've tried all the common tricks (verify permissions, command line, free unlocker tools, etc).
What finally got rid of them for me was 7-zip. Using 9.20 "7-zip File Manager" interface (not just the right click on file options) I was able to "Move" the folder which contained the problem files. Sure, that just moves the problem but there is the beauty, you move them to a disk you can format: a VMDK, a thumb drive, etc... problem solved ;)
Inspired by one of the answers, but instead of using 7-zip I used WinRAR to archive the empty folder. Before archiving the folder there is an option to delete the folder after archiving, select that option and once the folder is a zip file, the folder should be deleted, and you can go ahead and delete the zip file. I am not sure if it will work for you but it worked for me after spending hours on the internet trying to find a solution.
Here is what worked for me.
Open command prompt
Browse to parent directory of the folder you want to delete
run 'dir /x' (displays short names - xxxxxx~1)
run 'rd xxxxxx~1' substituting the folder name you want to delete.
I had a problem where two Pictures folders would show under my user profile, and windows wouldn't let me delete the second folder.
Try putting the directory name in quotes:
rmdir /q /s "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc"
Otherwise the spaces in the directory name will be interpreted as argument separators.
The only solution that worked for me was to put \\?\ in front of the path when running rd in command prompt.
For example, to delete D:\bad\folder
Open CMD and then type:
rd /s "\\?\D:\bad\folder"
At a command line run:
ECHO %UserProfile%
What does it return?
Open that directory in Windows Explorer and double check that a folder called AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\abc exists in it.
I'm thinking that maybe it doesn't exist, and the folder you're looking at that you said does exist, is in a directory with a root that is different from %UserProfile%.
Update
Open a new command window by doing the following, which ensures that it's in Administrator mode.
On a Shortcut to a command window, Right Click > Properties > Shortcut > Advanced and check the "Run As Administrator" checkbox, and click OK twice. Then run the command prompt via the shortcut. You'll know it worked if it looks like this, with the word "Administrator" in the title, see screenshot below. Then try running your RD command again.

How to use RunAs Cmd to Launch Explorer, Windows 8

any idea why this is not working?
runas.exe /user:Administrator "cmd /c explorer"
it returns:
Windows cannot find the specified file. You may not have appropriate
permissions.
the following works by itself:
cmd /c explorer
thx!
Answer found here
http://winaero.com/blog/how-to-run-explorer-as-administrator-on-windows-8-1-windows-8-and-windows-7/
"Microsoft does not allow running Explorer as administrator in Windows 8.1/8 (and in Windows 7 too). The solution to run Explorer elevated...
1- take ownership of registry key below.
Right-click, Permissions, Advanced, Owner Change
or, Use Winaero's RegOwnershipEx application, which allows you to take ownership of registry keys
HKEY_CLASSES_ROOT\AppID{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}
2- rename or delete the value named 'RunAs'.
3- now Restore Ownership (this failed for me done manually-- i could not re-add TrustedInstaller --user not found).
4- at this point, you will be able to run explorer as admin
5- this process does not cleanly exit when you close the Explorer window! You must remember to terminate it every time you elevate Explorer after you are done working in the Explorer window.
Alternate solution: use Winaero's ELE.exe app to start any program as administrator from the command line.
Usually one wants to run as an Administrator to edit a file, or get permissions to delete a file:
To get to the permissions on a file you can right click on it and select Properties. Then select Security. You will see this dialog:
Then Click on Edit and change the permissions for the relevant user (e.g Mike).
You need to have admin privileges to do this, which can be set via User Account Control.
The File Permissions window looks like this:
Edit as required.
I have admin rights but Windows 8.1 still protects some system files (such as the Android studio.exe.vmoptions) and I used the above method to give me write access to the file.
Hope this helps.
You could always open a dos prompt as Administrator then go to the directory in question then do a Explorer . then it will open the location in question as the elevated user.

How to create a universal windows shortcut?

I have created a shortcut for my program (under Windows 7), whose target is in a sub-directory. But when I zip everything and send it to my colleague, the shortcut wont work because it the target directory cannot be found, it is like:
Target: C:\Users\my_user_name\Desktop\my_program\sub_directory\my_program.exe
and the shortcut is in C:\Users\my_user_name\Desktop\my_program\
When I send it to another PC, my_user_name directory cannot be found and shortcut doesnt work. How to solve this?
Create a batch file that launches the program. You can then use a relative path.
e.g.
C:\Users\my_user_name\Desktop\my_program\launch.cmd
cd sub_directory
start my_program.exe
possible solutions:
place the program with the exe on disk like c:\program\programname\ Location must be the same on all computers.
place the program with the exe on the network where you can both access, shortcut is the same
edit the shortcut in notepad and change the user

How do you add Start->Run shortcuts in Windows XP?

Does anyone know how you setup new commands to launch an application from the Start->Run box?
ie. you can type "firefox", "winword" or "excel" into the Run box and those applications will open even though they're not in the system path, but others won't. For example, with Firefox, there's no files named firefox.* in any of my system path directories:
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Subversion\bin;c:\Program Files\Microsoft
SQL Server\90\Tools\binn\
So there must be some way of linking applications with this path to create a shortcut command, maybe in the registry?
For example, I want to be able to launch Google Talk from the Run command, but typing the executable's name "googletalk.exe" doesn't do anything, which makes sense because it's not in the system path, but neither is firefox.exe, and typing "firefox" works.
Does anyone have any ideas?
From http://commandwindows.com/runline.htm:
Adding applications to the Path
Alternatively, the Registry can be
edited to explicitly contain the path
to the desired executable file or
files. The Registry key involved
isHKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App
Paths
Create a new sub-key with the name of the executable file that you
wish to add to the path. e .g.,
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App
Paths\somefile.exe
In this new key, add a string variable named "Path" containing the
value of the the path to your new
executable file, e.g., C:\Program
files\newprogramfolder\
The new key will already have an empty variable (Default). Edit it to
have the string value of entire
address of the new program executable , e.g., C:\Program files\newprogramfolder\somefile.exe
3 steps.
Create a shortcut to the foo.exe you want to run (foo.lnk)
Copy the foo.lnk to your C:\windows directory.
Run foo.exe by simply typing "foo" in your run dialog. ("start foo" in cmd prompt works too)
You could also use an application launcher like Launchy, Slickrun or Executor. That way you wouldn't have to mess with the registry. I use Executor and I can just select "send to -> executor" to create a shortcut for any app (or folder or whatever).
Run works with search paths, which include the Path environment variable and some others. There might be more information in the MSDN, give me a moment and I'll look it up.
I put a link to the application I want to launch in the "c:\windows" folder, and I use it all the time. You can also rename the link file, of course, to speed up things: for example, I type w, x or pp to launc Word, eXcel or PowerPoint.

Resources