Using 'net stop wlansvc' works from a command prompt - as long as you pick 'run as administrator'.
I want to do it the hard way (instead of a batch file) which means using the SCM, which means elevation.
What is the best way to do it? I have seen code adjusting token privileges, using a manifest...
Background:
A game I play (NFS Undercover) connects to the internet to download ads (these are textures for the various billboards in the game).
The only trouble is that it can take up to 5 minutes for the game to start, since that's one of the first things it does.
If I remember, I disable my net connection before I start the game, but sometimes (well, quite often) I forget.
I even put a special rule in windows firewall (this is win7), it is 'block all' for incoming and outgoing, but still goes through.
try sticking
Quoterunas /user:Administrator net stop wlansvc
in a batch file (untested; you might need to fiddle with the syntax) - it will request the password, and then run the command as the given user.
i'd get the url for the ads and put it my hosts file
127.0.0.1 www. ad_url. com (remove the spaces from the url)
sinsi,
Here is some stuff I wrote as an example of how to run a program or a task "elevated" in Windows Vista (works with Windows 7 too).
Run Elevated (http://www.masm32.com/board/index.php?topic=9422.0)
Tedd: batch file doesn't work properly - when the game ends the batch console window is gone but cmd.exe is still there (possibly because the damned game has a console window too). Another PITA is having to type the password twice for runas...
dave: can you recommend a program to let me see that url?
Greg: That's what I was referring to in my original post. This is twice now I have needed it but couldn't remember the thread (and I posted to it!). Bookmarked now.
If I start another process from my elevated one, is the new one elevated as well?
OK, I've gone with my code and Greg's manifest - works perfectly.
step one: OpenSCManager/OpenService/ControlService/CloseServiceHandle to stop
step two: CreateProcess/WaitForSingleObject until it finishes
step three: OpenSCManager/OpenService/StartService/CloseServiceHandle to restart
Thanks for the input fellas.
i think there is a console mode program that lets you see what urls are hit
i was playing with this at one time, to get rid of ads from yahoo messenger
with the last 10 or so versions of messenger, i have had to patch the exe file instead
so, i have forgotten how to get the info
one thing you can do is look in your temporary internet files
in the Content.IE5 folder, the urls are given
start by cleaning out the temp int files using internet options
then go in and physically clean it out - many non-indexed files get left behind
leave the favicons alone - they are desirable
then, fire up the game wait for it to load - and exit
go back into Content.IE5 and see which urls the ads came from
Nah, the game connects to an ip (url or address, dunno) and downloads .png files - these are the 'ads' in the game world itself (billboards), not webpage ads.
The thing that pisses me off is that i specifically made rules in windows firewall that explicitly block the program - inbound and outbound. It still gets through.
What the f**k does 'DENY ALL' mean then? *grumble*
lol
well - if you look in the temp internet files, you will see the png files
if you look specifically in Content.IE5 folder, you can see the urls
trust me - lol
I thought if you used sockets it didn't touch the IE cache.
Anyway, in win7 I can't even get into my 'local settings' dir - SYSTEM owns it and ain't letting go of it :bdg
No big deal.
that would bug the shit out of me - lol
i would be finding a work-around real quick
otherwise, the left-overs in the temp-internet-files will suck up all your drive space
i would either find a way to log in as "System", or i would find the right button to mash that changes permission for that folder
Presumably, the main program launches another app to do the actual downloading of billboard images. So, you're blocking the main app, but not the one that actually does the downloading - hence it doesn't get blocked.
You might have to do some digging, but if it's dynamically unpacked (randomly generated filename) then it won't be pretty.
Having trouble with the firewall, huh ?
On my Win7 64bit I use Windows 7 Firewall Control :
http://www.sphinx-soft.com/Vista/order.html
Ultra light-weight !
Just set your rules and nothing goes through. The windows firewall doesn't fit my needs.
Quote from: sinsiIf I start another process from my elevated one, is the new one elevated as well?
I think so, but I'm not sure, it's been over a year since I worked with that UAC stuff.
The following is some good information about it:
Inside Windows Vista User Account Control (http://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx)
BlackVortex: unfortunately, the game takes even longer to load :(
Greg: yes, the child inherits the parent user token.
yah - i have a friend that uses vista 64-bit
we were working on a program together
he opened the console with "run as administrator"
then ran the console app - it ran as admin
Hi,
Probably a dumb question, but what happens if you
turn off the modem/router or unplug the cable?
Curious,
Steve N.
No cable to unplug, I'm using wireless. If I turn the router off, the other 2 computers in the house won't have internet...