Jump to content

Post-automation Cleanup


Recommended Posts

I would have thought others would have asked about something similar before, but I can't seem to find anything about making an AutoIt exe delete itself after execution (then again, my searching skills are far under average).

At the computers where I work, we use an ugly program called CleanSlate to reset the state of the computer after users are done with them so that they can not make any undesirable changes to them. Obviously, this means it gets in the way when we actually want to change things; so we have to turn CleanSlate off first, reboot after changes, then turn it back on. And that is what part of the scripts in question are supposed to do.

I wanted the main script to copy "cson.exe" (stands for "clean slate on") to the all-users startup folder, then simulate a windows key then "u" so I just have to walk around the room and select "reboot" on each computer after everything is done. Then, when cson.exe runs, since it is in startup, I want it to turn CleanSlate back on then delete itself. When testing cson.exe, it wouldn't delete itself, which makes sense since the account it's run under doesn't have permission to modify the all-users folders.

To get around the permissions, I tried using RunAsSet to make it use my account.

...
RunAsSet("myUserName", "theDomain", "myPassword", 2)
Run(@ComSpec & " /c " & 'del "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\cson.exe"', "", @SW_HIDE)

I also tried that with the last argument to RunAsSet being 1. In both instances, it failed to delete cson.exe.

I haven't added the part to the main script which copies cson.exe to the startup folder yet; for now I'm just manually placing it there. I assume, however, that getting it to place the file there should fail the same as deleting it, so this will also help me solve that problem when I get there.

Thanks in advance for any insight.

Link to comment
Share on other sites

I would have thought others would have asked about something similar before, but I can't seem to find anything about making an AutoIt exe delete itself after execution (then again, my searching skills are far under average).

It's Q12 on this FAQ.

:)

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

Thank you, and sorry I cluttered the forum with something that was answered in a FAQ. :)

You get a pass on the FAQ, because I had to search for that particular one (there are several). This question is not answered in the FAQ sticky at the top of this forum.

...hint to Jon...

;)

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

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...