Windows 8 issue: batch files can't interact with program files folder?

Grall

Invisible Member
Legend
I'm trying to make a bat file to delete ONE single temporary file which another program re-creates regularly to re-set the contents, and windows 8 just won't let any commands interact with the program files folder in any way.

Not even:
Code:
cd c:\program files\blahablaha
dir
works; the CD command is ignored, and DIR gives output of the folder where the bat file itself resides.

How the BLEEP can I override this annoying-as-you-know-what behavior?
 
It's because the default Program Files folder is a somewhat system protected folder. You need Admin rights to made changes to files in there. Note that default is whatever location Windows has in its registry for the program files location. This is to make it a bit harder for malware to make changes to files in that directory.

This is easily solved by just installing files to a different location. On my system I use my "G:" drive for games while using the default for most applications. But I keep the path the same so when installing a game, I just change the drive letter.

Long story short, if you run the batch file with admin rights it may work. I'm not sure if commands in the batch file inherit the admin status of the batch file, however.

Regards,
SB
 
Two things:
Run the script as admin.
Put your full path in double quotes cd "c:\program files\blahblahblah"
 
I will try the admin thingy, thanks. :) Double quotes or no never made any diff in the past, but will add for the final script, of course... :) Bloody windows, eh? My account is already admin (and yeah I know you're not 'supposed' to do that but windows UAE already prompts about enough shit as it is, I can do without even more headaches), and still you need even more admin privilege shit just to run a simple script operating on files which aren't windows system files to begin with.

I'd tell windows to go fuck itself if only I could. Would be a pleasure at this point.

Edit: that trick worked a charm, thank you Buddha and Albu. Of course, I had to google and read you make a shortcut to run bat files as admin... Ugh, is there a smoother workaround for that maybe? :D

Btw, can some mod move this thread to the PC software forum? I don't know why it ended up here! :D I must be going senile or something...
 
Last edited by a moderator:
Why are you making a bat file? Why can't you just make a scheduled task which you can run as any user you want and you can run it on demand or on a schedule or both?
 
...Cuz, this is the only way I know how. :p :oops: Also, it's pretty quick and convenient, if I didn't have to jump through hoops to get it to work that is. However if you can let me know how to set it up in a better way I would be most grateful!
 
Go to administrative tools and open task scheduler. Go into the task scheduler library and create a new task. The wizard has a huge amount of options. Try it :)
 
If the filename is always the same, why not create an empty file of the same name then remove write access to it :p
(there's even a little trick to create such a file : copy nul file.txt)

How your program will behave, I don't know (bomb, do nothing, swear at you?)
About UAC, I like it fine. I run a normal user account, and configured UAC to prompt for the admin password, which suddenly makes sense. (Windows 7, I've just launched it after a long lull.)
Right-click on a shortcut to cmd.exe with "run as administrator" is useful. I've just seen that launching the device manager, devmgmt.msc from that prompt works (else, the device manager was read-only and I had to do a full, desktop admin log in)
 
Last edited by a moderator:
I think the program (it's actually a game, world of warcraft :p) would not like not being able to modify one of its own temp files TBH. I'd rather just kill the file (I'm thinking on bootup, as I typically shut my PC down at the end of the day.) Anyhow, the bat file approach actually works pretty well, if I do it as a scheduled task, when would I schedule it so I am not gaming when the scheduled task runs? I can run the bat from autostart folder in a minimized window, it never even appears on screen.
 
Hidden batch on autostart is damn good enough ; to make things complicated you would have a task that runs hourly, tests for the presence of wow.exe or such in the list of running processes and delete the file if wow is not running.

In cmd.exe the tasklist command shows processes, then how do you mangle data I don't know (some ugly crap with ports of unix tools and IF ERROLEVEL GOTO) but at that point you should be using powershell, or easier, auto-it / autohotkey.
 
Yes, except these days blizzard titles using battle.net (ie: wow, diablo3, starcraft2) has a unified launcher that runs at startup and handles patching, launching the game and so on. So that approach would mess somewhat with blizzard's setup. Thanks anyway for the tip though.
 
Task Scheduler has a, well,s scheduling drop-down box that allows for things like "on startup", "on logon", "on logoff" and "on shutdown" among a ton of others. Just do it "on logon", with the "User must be logged on" and "administrative rights" all checked.
 
Task Scheduler has a, well,s scheduling drop-down box that allows for things like "on startup", "on logon", "on logoff" and "on shutdown" among a ton of others. Just do it "on logon", with the "User must be logged on" and "administrative rights" all checked.

I have used task scheduler before and I too recommend it. It is an awesome little thing that most people probably never ever use or are even aware of.
 
Back
Top