Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there a way to unlock Windows files without downloading a utility?
I have a few files on my Windows XP C: drive that are very old and very useless. When I try to delete these files I get the following message:
Cannot delete FILENAME.zip: It is being used by another person or program
Close any programs that might be using the file and try again.
No one is accessing this file. No program is using it currently. Windows has screwed up the file locking mechanism.
Is there a way to delete this file without downloading someone's unlocking utility? I find the sites offering these programs to be a tad sketchy.
How could you force the file to unlock from within a program? I'm competent in Java, Perl, and Ruby, but I haven't seen anything among their libraries that would aid me here.
I've successfully used Process Explorer to find out which process has the file open. It saves a reboot that may not fix the problem anyway.
In process explorer: Find > Handle or DLL... then search for the name of the folder/file, then double click one of the search results. It'll select a handle in the main window, which you can right click and close.
Try downloading "Unlocker". Google it and take my words that it doesn't have any worm/spyware/virus. It is pretty cool utility and works great. Give it a try.
Did you try the commandline command OpenFiles
It is built in (XP and above I believe) and has several arguments that can be passed in.
Use msconfig and start up with everything turned off.
Then try to move / delete the file.
Or you can always boot up in safe mode and delete it.
You do that by hitting f8 when the machine boots up.
If you reboot and the files are still locked, then there is some process on your machine that is still using them. First you should figure out what that process is and determine if the files really aren't used any more or not.
Rebooting to Safe Mode is often a very easy way to do it. When you boot in safe mode, it won't load all the stuff set to run on startup. Press F8 while it's booting to access the boot menu, and choose "safe mode".
I had a .jpg pfile that hasd that issue and I couldn't delete. That brought me to this thread. When nothing else worked I renamed the file and left off the .jpg. THEN I could delete it easily. Not sure why, but worked for me
You don't need any utility.
Just use Win32 api to unlock them (simply close the handle)
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a specific piece of hardware which I'd like to disable and re-enable each time my Windows restarts. I created a batch script which is supposed to do that, along with running my program afterwards:
cd %~dp0
devcon.exe disable "PCI\VEN_1002&DEV_687F"
timeout /t 3
devcon.exe enable "PCI\VEN_1002&DEV_687F"
runMyWindows.exe --totally-not-virus
I am not sure if devcon.exe is a proper application for this in the first place because I have no experience with writing Windows scripts at all.
However, I have noticed that those commands don't quite do the job because my runMyWindows.exe program doesn't work as it should until I go to Windows Device Manager and manually disable and re-enable this device.
I have only 1 user on this machine which is in "Administrator" group and I am not running this script in any special way except double-clicking the .bat file, or in case of the restart, it is run from the startup folder (C:\Users\oxxo\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).
Is there a way to do this properly within my batch script which should be run automatically on Windows startup?
PnPUtil do this job also and no SDK or anything else related required to download.
Included in Windows since Vista:
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil
Examples
Disables device specified by device instance ID:
pnputil /disable-device "USB\VID_045E&PID_00DB\6&870CE29&0&1"
Enables device specified by device instance ID:
pnputil /enable-device "USB\VID_045E&PID_00DB\6&870CE29&0&1"
Most people who'll be reading this thread won't find the other answer very useful, because it's mostly about how to run the script in the question with administrator privileges. I'll attempt to answer the implicit questions here:
Enable/disable a device via the command line
I found it easiest to use devcon.exe (6mb), like in the question:
set HARDWARE_ID="PCI\VEN_8086&DEV_4229&SUBSYS_11018086&REV_61"
devcon disable %HARDWARE_ID%
timeout /t 3
devcon enable %HARDWARE_ID%
devcon.exe requires administrator privileges.
Where to get devcon?
It's part of the Windows driver development toolkit. Unfortunately, the official resources ask you to download a 1gb SDK. I was able to get around that by following one of the answers here: https://superuser.com/questions/1002950/quick-method-to-install-devcon-exe
Once you have it, make sure devcon.exe is on your %PATH%. I put mine in C:\Windows\System32\.
Find the hardware ID of the device you want to manipulate
Open a Command Prompt with administrator privileges and do devcon hwids *, which will print all the devices and their corresponding IDs. That will produce a lot of output. Use Command Prompts search function to find what you need. Here's the section I was interested in:
PCI\VEN_8086&DEV_4229&SUBSYS_11018086&REV_61\4&6AB551C&0&00E1
Name: Intel(R) Wireless WiFi Link 4965AGN
Hardware IDs:
PCI\VEN_8086&DEV_4229&SUBSYS_11018086&REV_61
PCI\VEN_8086&DEV_4229&SUBSYS_11018086
PCI\VEN_8086&DEV_4229&CC_028000
PCI\VEN_8086&DEV_4229&CC_0280
Compatible IDs:
PCI\VEN_8086&DEV_4229&REV_61
PCI\VEN_8086&DEV_4229
PCI\VEN_8086&CC_028000
PCI\VEN_8086&CC_0280
PCI\VEN_8086
PCI\CC_028000
PCI\CC_0280
Pick a specific enough ID and check if it works by doing:
devcon find "PCI\VEN_8086&DEV_4229&SUBSYS_11018086&REV_61"
If that finds only 1 device, and it's the one you want, you're good. Notice that often you'll want to escape the hardware ID with quotes.
Bonus: running a .bat script at startup or power on
In my case, I also needed to run this script when computer has booted after shutdown or sleep. I gave the above script sensible permissions and used Task Scheduler to run it on login and on startup, in its terminology:
https://www.sevenforums.com/tutorials/67503-task-create-run-program-startup-log.html?ltr=T
Due to security 'improvements' in Windows 10 and certainly since Windows Vista and the introduction of User Account Control I assume you would need to Run as administrator, not just be a member of the Administrators group.
It should generally be read that Run as administrator means Run as the user with the account name Administrator not Run as any user who holds membership of the Administrators group.
To Run as administrator, right click on the batch file and select Run as administrator from the context menu.
There are other ways of running as Administrator too.
You can use a self-elevating batch file, which usually uses a PowerShell or WSH helper function.
You can use Task Scheduler and choose the appropriate triggers and account information, (possibly using the SYSTEM account).
Additionally you need to ensure that DevCon.exe is either:
Along side the batch file, "%~dp0DevCon.exe" Disable "PCI\VEN_1002&DEV_687F*"
At a location defined within %PATH%, DevCon Disable "PCI\VEN_1002&DEV_687F*"
Invoked using its full path, "C:\Tools\DevCon.exe" Disable "PCI\VEN_1002&DEV_687F*"
In all cases above please note the asterisk which is missing from your examples
This question already has answers here:
How do I update the running EXE?
(2 answers)
Closed 8 years ago.
I write a very tiny TSR program (passwordmanager.exe) and have two very small files of records.
Actually i save all files (exe, data) to one USB-Stick the user always transports, wherat the data contains sensible data.
Is there any technique to modify the internal resource of the passwordmanager.exe itself that is currently running? As far as i know the exe is copied to the RAM, so the passwordmanager.exe may have no write lock and i am able to let the passwordmanager.exe grow if the user enters new Passwords.
Why do i think this may work? Years ago i had a MSDOS program who asks for the password but unfortunatelly the user has forgotten his password. As i printed the contents of the MSDOS-Program to the console the user luckily found his password in the machine-code!
Question: How can i store the two very small files of records into the exe?
In your comments you wrote "Yes the antiviral program will get upset, i dont care"
Well, if you don't care that your program might be blocked. and you have write permissions to that USB device, I can think of a pattern like this:
Copy your running.EXE (Application.ExeName) to a patch.EXE (via CopyFile) - or generate that patch.EXE from a Resource (Antivirus would NOT like this!).
running.EXE Execute/Create new process patch.EXE with parameters e.g.
patch.EXE /update /your_record_parameters /pid:running_process_id
patch.EXE will start and check for /update; Signal running.EXE to shutdown; Wait for it to shut down; patch running.EXE; Execute running.EXE /patch_done; Shut down itself.
Finally, running.EXE could clean up now by checking the /patch_done and Delete patch.EXE
On NTFS, you could use alternate file streams:
http://support.microsoft.com/kb/105763
(I remember round about when Win2K first came out, seeing a magazine article (UK PC Pro) which showed how to use Notepad to store a secondary stream in an .Exe and was astonished that any OS with pretensions of security would provide this facility, but there you go.)
A tool for viewing them:
http://www.nirsoft.net/utils/alternate_data_streams.html
Is there any technique to modify the internal resource of the passwordmanager.exe itself that is currently running?
No there is not. When a process is started its executable file is locked exclusively and so cannot be modified.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
My system crashed whilst I was in the middle of updating an .aspx page in visual studio 2010. When I rebooted my PC and started visual studio again the .aspx file was still there, but when I clicked to open it in solution explorer notepad opened and a blank file was displayed. Looking at the file in windows explorer the file still has it's size of 31Kb, My file content was replaced with some white space characters
Any suggestions to how I might recover this file? I've spent a 4-5 days of work, with no backup - arrh! any help would be really appreciated
Though Old post, sharing my experience :D
I faced the same problem with a file today and overcame it successfully. :D
Felt freaking heavenly after getting my file back ... :D \m/ :D
Here is the solution. Actually, there can be two types of solution of recovering corrupted files I found.
Scenario: Your file is corrupted (ie. null or space everywhere in the file while the size is ok)
Solution #1: Using file recovery software.
File recovery softwares can recover a file when it is already deleted.
In our scenario, your file is not deleted but corrupted. So how to use
the software in this case!!!!
Just delete your file
Try to recover your deleted files with popular file recovery softwares
And voila ... it is recovered ... :D
The recovery software I used is Recuva. Worked perfectly.
Solution #2: If its a web content, like CSS/Javascript/html etc.
You can collect the last working copy of the file from browser cache,
IF and ONLY IF you hadn't opened the corrupted webpage in that brower.
The thought that help me finding the first solution is from
Mark Twain - "Never argue with stupid people, they will drag you down to their level and then beat you with experience."
While I was thinking how to use this recovery software, I thought about this quote and said myself "LETS DRAG THE FILE DOWN TO THE LEVEL, WHERE RECOVERY SOFTWARE CAN RECOVER" ... :D
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
On my Mac, there is no window open when I start Terminal app. I just played with a friend's Mac, a window is automatically opened on startup of terminal. He doesn't know how it's done. I just played with preferences and couldn't find anything for that. Does anyone know how to do that?
I'm just grasping at straws here: is it possible that your Terminal program is always running in the background, and you are not actually completely exiting? You can perform this test: Run Terminal in whatever manner you usually do, and then press Command-Q to quit the application completely. Now run Terminal again. Did it open a new window?
The Mac has a slightly different paradigm on open/closed applications, namely that closing the last window doesn't actually quit the application. Combine this with the fact that Mac users rarely ever actually reboot their computers, and it's easy for relatively novice Mac users to have many applications that are simply running in the background that are never closed completely.
Just a shot in the dark. If you are for sure exiting the app completely than I can't think of a solution for the problem either.
Create a Windows Group
Go to Preferences -> Start, and select the windows group to open on start up
From the Terminal App, choose Preferences: select Startup and verify that the "On startup, open new window with settings:" radio button is selected and select Basic from the pull-down menu. That's all I have and it starts up with an open window for me.
If you've tried all the above suggestions, see if anything weird is appearing in your console. Open up /Applications/Utilities/Console.app and watch the "All Messages" log while you open Terminal.
You could try one of the other terminal apps that are out there for Mac. I prefer iTerm, it's free and works very well. It also gives you nice features like tabs, color schemes and fullscreen terminals.
You can also try this out, it is a Ruby gem that lets you automate opening mutliple tabs that run preset scripts or commands: https://github.com/Achillefs/elscripto
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
My printer ran out of black toner and I didn’t have a spare, so I thought it’d be a good idea to “print” documents to .XPS files for now, then print them when the new toner arrives.
So, now I have my toner but I can’t work out how to print the files. I found this great post on Tim Barcz’s blog which seems to indicate I’m not alone.
I can open them and view them in IE, but if I try to print them it either ignores the command altogether or crashes.
I downloaded the XPS Essentials Pack from the Microsoft website and tried to install it, but it refuses to install and keeps crashing with a ten-page error message. Ironically, I would normally print this message out to deal with it.
My “solution” is to open the .XPS files in IE, then screenshot them and paste them into Paint Shop Pro so I can print them as graphics.
As Tim Barcz says in his post that I linked to:
That’s it…simple. What I don’t get is why people are so afraid to embrace new technology?
I have had no problems printing XPS docs from IE. The first thing that comes to mind is what OS are you running, what version of IE, are all service packs installed, etc?
Another option would be to copy the XPS files to a thumb drive (or send over the network) and print from another computer that does not have any issues.
Edit:
Follow up questions...Can you print non-XPS docs? Have you restarted the printer? Is your print spooler messed up?
I have had many instances where I could not print due to a bad print job clogging the spooler. Restart the spooler or restarting your PC usually takes care of this issue.
IE has an issue with printing XPS files to a network printer, is this a network printer?
The short answer to printing XPS is to use the "Microsoft XPS Document Writer".
This 'printer' gets installed when you install Essentials Pack/XPS Viewer on your system. IMHO, it is better to install the former. Note that MS has upgraded the EP from RC to 1.0 sometime back. So, probably, the problem you have is one of using the older EP. Now, downloading and installing the newer EP (i.e. EP 1.0) doesn't work always. The safest bet in this case is to manually uninstall the EP RC Pack, and then install EP 1.0.
Also, remember that you'd probably have to uninstall/upgrade the installed .NET runtime (or reinstall it). Oh, and then there is MS Core XML Services 6.0 that is required for MS XPSDW (the printer I mentioned earlier, remember?) to work. However, a quick look back at MS's site (http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en#Requirements) tells us this is supported for upto XP SP2. Check with MS to know if SP3 is supported as well.
In case you manage to get around all this somehow, you'd want to view the output of the prints you fire. I have the IE-tab extension on my browser and I open all XPS files using this one. Recently, however, I've heard that Pagemark has come up with a ff plug-in for viewing XPS files. You might want to check it out (http://www.pagemarktechnology.com/home/xps-test.html).
And of course, check out Wikipedia (http://en.wikipedia.org/wiki/XML_Paper_Specification)!
If you don't want to print to XPS, select another printer as the default one as indicated by previous comments. Also the XPS printer seems to have problems with margins or page size (some information are outside the A4 or too close to border to be printed).
Otherwise, when opening XPS files in IE9, the "File>Print" menu option is disabled. But you can use the keyboard shortcut: Ctrl+P
There are XPS to JPG/JPEG converters all over the web, pick one ;/
I had big problems with the XPS essentials pack, too.
After a lot of research and debugging I found the installation of XPS to be damaged somehow, and just scrapped and reinstalled the whole computer.
Afterwards everything XPS did work like charm.
So my guess would be: your XPS installation is faulty. Fix: reinstall. Workaround: print from some other computer.
With all due respect to the other answers, I believe you're overlooking the most likely cause and the easiest solution. The most likely cause is that the person's default browser is not Internet Explorer. The solution in that case is to open IE and type in the address of the xps file (e.g., C:\Users\Public\Documents\EVIDENCE\groupon.xps
Windows XP SP3, IE6, all up to date AFAIK.
I use Firefox mostly, so haven't updated IE for ages. Maybe IE7 would be more successful.
The point was that XPS is meant to be some kind of PDF-killer, but the difference is that PDF just works, while XPS has been a disaster. I don't mind errors, but I want it to tell me what is wrong, not just say it didn't work, as I can see that from the lack of pages coming out of the printer.
My answer: anytime you need to resort to 'steps' to resolve an issue that normally 'just works' in any other format, you have by definition gone beyond 'just works' to that place where you need to do work to make something 'just work'.