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.