topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 8:19 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Idea: Run once and then delete  (Read 7800 times)

usasma

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Idea: Run once and then delete
« on: May 13, 2007, 07:33 AM »
I've tried doing this myself and it doesn't work for me :(

The idea is to have a file that the user can double click on to change registry settings and it will automatically insert a registry entry that will remove the registry settings on the next reboot.

This is an attempt to enter the proxy server information from work into a computer's registry so that system can access the web.  Then, when the computer is taken home, the reboot will take care of removing the proxy settings.  This'll help us when we forget to remove the proxy before sending it home.

Even better would be a tool that would do this for all the major browsers.

Here's the registry entry that's used for starting the proxy:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="xxx.xx.xx.xx:8080"

And here's the one that's currently used to turn it off:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:0000000
"ProxyServer"=""


Thanks!
 - John



edbro

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 426
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #1 on: May 13, 2007, 09:05 AM »
You could create a batch file that would load the new reg setting and put it in your startup folder. Save the settings that turn off the proxy to a file named remove.reg. Don't forget the proper reg header. Then create a file named noproxy.cmd and put it in your startup folder.

noproxy.cmd
\REGED /S path to file\remove.reg

usasma

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #2 on: May 13, 2007, 08:02 PM »
I'm a real simpleton when it comes to writing stuff - can't figger out why this doesn't work!

Here's my batch file:
regedit /v ProxyOn.reg
xcopy ProxyOff.reg %ALLUSERSPROFILE%\*.*
regedit /s DelProxy.reg

I get an "Invalid number of parameters" error when executing the line with xcopy in it - so the batch doesn't finish properly.  If I execute the batch file in a cmd window - I get an error in importing the ProxyOn.reg file also.

Here's the rest of the reg files:

ProxyOn.reg:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
"ProxyServer"="xxx.xx.xx.xx:8080"

ProxyOff.reg:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:0000000
"ProxyServer"=""

DelProxy.reg:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
"ProxyOff"="regedit.exe /s %ALLUSERSPROFILE%\ProxyOff.reg"
"DelProxy"="del %ALLUSERSPROFILE%\ProxyOff.reg"

edbro

  • Charter Member
  • Joined in 2006
  • ***
  • default avatar
  • Posts: 426
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #3 on: May 13, 2007, 08:36 PM »
regedit /v ProxyOn.reg
Where did the /v switch come from?  The /s switch simply tells it to execute silently. I have never heard of /v.

I get an "Invalid number of parameters" error when executing the line with xcopy in it - so the batch doesn't finish properly.
It appears you can not use an environment variable in the xcopy command. Just spell out your entire path inside quotation marks.

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #4 on: May 14, 2007, 04:00 AM »
Why are you using the '*.*' after the '/' ?
I'd say that this would work:

regedit /v ProxyOn.reg
xcopy ProxyOff.reg %ALLUSERSPROFILE%\
regedit /s DelProxy.reg

usasma

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #5 on: May 14, 2007, 07:23 AM »
Why am I using the -v switch?  I copied it from another file while trying to make this thing work.  I'll get rid of it because I can't see any benefit to using it (the reference that I found indicates that it runs regedit in advanced mode - whatever that is)

Why am I using the *.*?  It's a holdover from my days using DOS :)  It's gone too!

As for using the entire path - I'd imagine that that'll work with standard directory structures.  What about those that are different? (that's why I wanted to use the enviornmental variable).

It's slow at work right now - so I'll modify the batch file as indicated and will give it a whirl.  Thanks!

usasma

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #6 on: May 14, 2007, 08:07 AM »
I tried it - still not working. 

The first line of the batch file works just fine when executing it.  I still get an error when trying to run it in a cmd window - but we won't be using it that way anyway :)

For the second line, I tried the C:\Docume~1\AllUse~1 path without success.  I tried the copy command (rather than the xcopy) - I get a "The system cannot find the file specified" error.  When I specify the path to the USB drive with the files, this line works just fine (G:\) and it even removes the proxy when all is done.

The third line doesn't delete the ProxyOff.reg - but that's a minor issue and it won't interfere with the running of the tool.

usasma

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #7 on: May 16, 2007, 07:24 AM »
I'm considering one of these solutions:
1)  Adding a path statement to the batch file that includes all possible drive letters that the flash drive could be assigned, or
2)  Copying the whole thing to the root/system root and running it from there via a batch file.  I'd have to add something to remove the files from the root/system root when it rebooted tho'

Any comments/suggestions?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Idea: Run once and then delete
« Reply #8 on: May 16, 2007, 09:18 AM »
Any comments/suggestions?
I think i'd go for the first option, as apparently a "del filexxx" entry in the 'run once' doesn't appear to work.