Jump to content

This Newbie needs some help scripting


Brimaster
 Share

Recommended Posts

I am not real good working with autoit when it comes to running exe's and reg fixes.

I am trying to run an uninstall and a reg file copy and execute for Spybot. If I run it though a bat file I can get it to work but under Autoit I just don't a clue on the correct commands to get this to work.

If someone can help me in the right direction that would be great.

Below are the commands that I am using in the bat file:

"C:\Program Files\Spybot - Search & Destroy\unins000.exe" /silent

RD "c:\Program Files\Spybot - Search & Destroy" /s /q

RD "C:\Documents and Settings\All Users\Application Data\Spybot - Search & Destroy" /s /q

copy \\servername\\spybot\\remove-spybotsd-settings.reg, c:\\windows\\temp\\*.reg

c:\\windows\\regedit /s c:\\windows\\temp\\remove-spybotsd-settings.reg

Everytime I try and make a script I can never get anything to work correctly no matter what commands I try.

I am sure this is easy but I just can't get it to work.

If anyone has an idea or direction just let me know.

Thanks in advance.

Link to comment
Share on other sites

I am not real good working with autoit when it comes to running exe's and reg fixes.

I am trying to run an uninstall and a reg file copy and execute for Spybot. If I run it though a bat file I can get it to work but under Autoit I just don't a clue on the correct commands to get this to work.

If someone can help me in the right direction that would be great.

Below are the commands that I am using in the bat file:

"C:\Program Files\Spybot - Search & Destroy\unins000.exe" /silent

RD "c:\Program Files\Spybot - Search & Destroy" /s /q

RD "C:\Documents and Settings\All Users\Application Data\Spybot - Search & Destroy" /s /q

copy \\servername\\spybot\\remove-spybotsd-settings.reg, c:\\windows\\temp\\*.reg

c:\\windows\\regedit /s c:\\windows\\temp\\remove-spybotsd-settings.reg

Everytime I try and make a script I can never get anything to work correctly no matter what commands I try.

I am sure this is easy but I just can't get it to work.

If anyone has an idea or direction just let me know.

Thanks in advance.

You want the following in the helpfile:

Run()

DirRemove()

FileCopy()

Run() again (regedit) - or: RegRead() and RegWrite()

Code it up and post it if you need more help... :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You want the following in the helpfile:

Run()

DirRemove()

FileCopy()

Run() again (regedit) - or: RegRead() and RegWrite()

Code it up and post it if you need more help... :lmao:

PsaltyDS,

I am making progress I just need a little help with the last piece with the reg entry. Have not got how to call regedit and to run the reg file. Do I use the @WindowsDir function or ?

This is what I was thinking:

run ("unins000.exe" [, @ProgramFilesDir"Spybot - Search & Destroy"[, /silent]])

DirRemove (@ProgramFilesDir"Spybot - Search & Destroy",1)

DirRemove (@AppDataCommonDir"Spybot - Search & Destroy",1)

filecopy ("\\servername\\Spybot_Removal\\*.reg", "c:\\windows\\temp\\*.reg",1)

Sleep 1500

run ("regedit.exe",[@WindowsDir"temp\remove-spybotsd-settings.reg" [,@SW_HIDE]])

End

Does this look correct?

Thanks for all the help!

Edited by Brimaster
Link to comment
Share on other sites

PsaltyDS,

I am making progress I just need a little help with the last piece with the reg entry. Have not got how to call regedit and to run the reg file. Do I use the @WindowsDir function or ?

This is what I was thinking:

run ("unins000.exe" [, @ProgramFilesDir"Spybot - Search & Destroy"[, /silent]])

DirRemove (@ProgramFilesDir"Spybot - Search & Destroy",1)

DirRemove (@AppDataCommonDir"Spybot - Search & Destroy",1)

filecopy ("\\servername\\Spybot_Removal\\*.reg", "c:\\windows\\temp\\*.reg",1)

Sleep 1500

run ("regedit.exe",[@WindowsDir"temp\remove-spybotsd-settings.reg" [,@SW_HIDE]])

End

Does this look correct?

Thanks for all the help!

No. (But kudos for posting code with your question!)

Some things to fix:

1. Don't use the square brackets you see in the help file. They only indicate the parameter inside is optional.

2. To assemble a string from multiple parts, use the ampersand "&" operator, i.e. @ProgramFilesDir & "\Spybot - Search & Destroy"

3. You don't have to double up your backslashes as though escaping them from the DOS command line (in your filecopy() command). Though you would still need them at the begining of a properly formatted UNC, i.e. "\\servername\Spybot_Removal\*.reg"

4. When you copy multiple source files (*.reg), only specify the destination directory.

5. The sleep() command is not needed if you meant to wait for the filecopy() to complete. The script does not continue untill that function completes.

6. END is not a valid AutoIT keyword.

7. For readability, use the code tags on this forum around your code. Just highlight the code and then click on the Code button above the edit box with the pound sign in it: #.

Apply those fixes and post your code again, you're moving in the right direction!

:lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

PsaltyDS,

I started to make the changes and the first entry has an issue:

run ("unins000.exe" , @ProgramFilesDir"\Spybot - Search & Destroy", /silent)

First it does not like the silent command. This is what the spybot line parameters state should work. Tried the @SW_HIDE and that does not work either. So I removed it all together so I could at least make sure the uninstall worked even though it would prompt. When I try to run the uninstall command it states it can't find the specified file. It must not like the " - " and the " & " signs in Spybot - Search & Destroy. I must of missed something. So before I proceed with the rest of the script I thought I should double check.

Thanks again for your time.

Link to comment
Share on other sites

  • Moderators

PsaltyDS,

I started to make the changes and the first entry has an issue:

run ("unins000.exe" , @ProgramFilesDir"\Spybot - Search & Destroy", /silent)

First it does not like the silent command. This is what the spybot line parameters state should work. Tried the @SW_HIDE and that does not work either. So I removed it all together so I could at least make sure the uninstall worked even though it would prompt. When I try to run the uninstall command it states it can't find the specified file. It must not like the " - " and the " & " signs in Spybot - Search & Destroy. I must of missed something. So before I proceed with the rest of the script I thought I should double check.

Thanks again for your time.

Well your parameters are wrong and you're missing an '&' after @ProgramFilesDir.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

SmOke_N, your right I type like crap and that is one of many of my issues. :lmao:

MHz, I added the code you supplied and that worked. :ph34r:

I would of never gotten that. I have no idea how I could do this stuff without this forum.

So here is what I have come up with:

$path = @ProgramFilesDir & '\Spybot - Search & Destroy'
RunWait('"' & $path & '\unins000.exe" /VERYSILENT /NORESTART', $path)
DirRemove (@ProgramFilesDir & "\Spybot - Search & Destroy",1)
DirRemove (@AppDataCommonDir & "\Spybot - Search & Destroy",1)
FileCopy ("\\servername\Spybot_Removal\\*.reg", "c:\windows\temp\*.reg",1)
RegWrite ("remove-spybotsd-settings.reg")

Does this look correct?

Thanks again for the help.

Link to comment
Share on other sites

SmOke_N, your right I type like crap and that is one of many of my issues. :lmao:

MHz, I added the code you supplied and that worked. :geek:

I would of never gotten that. I have no idea how I could do this stuff without this forum.

So here is what I have come up with:

$path = @ProgramFilesDir & '\Spybot - Search & Destroy'
RunWait('"' & $path & '\unins000.exe" /VERYSILENT /NORESTART', $path)
DirRemove (@ProgramFilesDir & "\Spybot - Search & Destroy",1)
DirRemove (@AppDataCommonDir & "\Spybot - Search & Destroy",1)
FileCopy ("\\servername\Spybot_Removal\\*.reg", "c:\windows\temp\*.reg",1)
RegWrite ("remove-spybotsd-settings.reg")

Does this look correct?

Thanks again for the help.

Still too many slashes and bad destination for FileCopy:

FileCopy ("\\servername\Spybot_Removal\*.reg", "c:\windows\temp\",1)

RegWrite() does not use .reg files. It writes to explicitly specified keys and values. You need to read up on that command in the help file or avoid it by using Run() to execute REG IMPORT instead.

:ph34r:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Still too many slashes and bad destination for FileCopy:

FileCopy ("\\servername\Spybot_Removal\*.reg", "c:\windows\temp\",1)

RegWrite() does not use .reg files. It writes to explicitly specified keys and values. You need to read up on that command in the help file or avoid it by using Run() to execute REG IMPORT instead.

:ph34r:

PsaltyDS,

I modified the slashes and did a test run of the script. It seems to have worked fully. The reg file looks to have ran and removed the entries. Is that possible without doing the other commands like reg import or regwrite?

Really confused now. :lmao:

Edited by Brimaster
Link to comment
Share on other sites

PsaltyDS,

I modified the slashes and did a test run of the script. It seems to have worked fully. The reg file looks to have ran and removed the entries. Is that possible without doing the other commands like reg import or regwrite?

Really confused now. :lmao:

The RegWrite() function with a .reg file as the only parameter that you showed in your code doesn't work that way. I don't know what else may have accomplished it for you. Perhaps the keys were removed by the uninstaller you are running. I suspect if you just comment that line out it will still perform exactly the same. If you really need the registry changes in that file applied, your choices are runing reg.exe with the inport command, or examining the .reg file and translating the actions into RegWrite() AutoIT commands.

:ph34r:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The RegWrite() function with a .reg file as the only parameter that you showed in your code doesn't work that way. I don't know what else may have accomplished it for you. Perhaps the keys were removed by the uninstaller you are running. I suspect if you just comment that line out it will still perform exactly the same. If you really need the registry changes in that file applied, your choices are runing reg.exe with the inport command, or examining the .reg file and translating the actions into RegWrite() AutoIT commands.

:lmao:

I got the reg file from safer-networking's site as they stated to completely get rid of Spybot that in addition to the uninstall to delete the two folders and to run this small fix to remove all remains from the registry.

Maybe I really don't need this piece.

I will compile the script and set SMS to run the exe on my test machines and see what happens.

Thank you everyone for all the help on this I really appreciate it!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...