Home > Software engineering >  Can't delete the program itself about!
Can't delete the program itself about!

Time:10-12


 '" KillMe. Exe program code: 
Private Sub Form_Load ()
Print "Hello World!"
Unload Me
End Sub

Private Sub Form_Unload (Cancel As Integer)
Shell CMD/c del "" "" & amp; App. EXEName & amp; ". Exe ""," remove yourself vbHide '
End Sub

'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

'" Book1. XLS "Excel VBA code:
Private Sub Workbook_Open ()
FileName=ThisWorkbook. Path & amp; "\ KillMe exe
"X=Shell (FileName, vbHide)
End Sub


Description: the role of these two code when open the "Book1. XLS" call "KillMe. Exe," the problem is run separately "KillMe. Exe" can delete their normal, but by "Book1. XLS" VBA calls "KillMe. Exe" remove yourself is not normal, how to solve?

CodePudding user response:

 Shell "CMD/c del nouse& Ren ", "" & amp; App. EXEName & amp; ". Exe "nouse, vbHide yourself '

CodePudding user response:

refer to the second floor zhao4zhong1 response:
 Shell "CMD/c del nouse& Ren ", "" & amp; App. EXEName & amp; ". Exe "nouse, vbHide yourself '
only or double-click the program to remove yourself, but not by Excel vba Shell calls,

CodePudding user response:

 Private Sub Form_Unload (Cancel As Integer) 
Dim f As Integer
F=FreeFile ()
Open "killmyself. Bat" for the output as # f
Print # f, taskkill/IM "" "" & amp; App. EXEName & amp; ". Exe "" "
Print # f, "del", "" & amp; App. EXEName & amp; ". Exe "" "
Print # f, "del killmyself. Bat"
Close # f
Killmyself. Bat "Shell", vbHide
End Sub

CodePudding user response:

The
reference 4 floor zhao4zhong1 reply:
 Private Sub Form_Unload (Cancel As Integer) 
Dim f As Integer
F=FreeFile ()
Open "killmyself. Bat" for the output as # f
Print # f, taskkill/IM "" "" & amp; App. EXEName & amp; ". Exe "" "
Print # f, "del", "" & amp; App. EXEName & amp; ". Exe "" "
Print # f, "del killmyself. Bat"
Close # f
Killmyself. Bat "Shell", vbHide
End Sub
test code, and the result is the same, use vba after the call is not delete the program itself,

CodePudding user response:

Try to set up the plan task, 1 minute delay execution killmyself. Bat
 
C: \ & gt; SCHTASKS/Create/?

SCHTASKS/Create [/S system [/U username [/P [password]]]]
[/RU username [/RP password]]/SC schedule [/MO modifier] [/D day]
Up [/M] [/I idletime]/TN taskname/TR taskrun [/ST starttime]
[/RI interval] [{/ET endtime |/DU duration} [/K]]
[/SD startdate] [/ED enddate] [/IT] [/Z] [/F]

Description:
Allows administrators to create the plan on a local or remote system task,

Parameter list:
/S system specified to connect to a remote system, if you omit the
System parameters, the default is the local system,

/U username specified command execution of user context,

/P/password specified for a given user context password, if you omit the
Prompt,

/RU username specified tasks run under the "operation mode" user
Accounts (user context), for system accounts, effective
Value is ""," the NT AUTHORITY \ SYSTEM "or
"The SYSTEM",

/RP/password specified "operation mode" the user's password, to prompt lose
Enter the password, value must be "*" or not, the system account
Ignore the password.

/SC schedule specified frequency plan,
Effective planning tasks: MINUTE, HOURLY,
DAILY, WEEKLY, or, ONCE,
ONSTART, ONLOGON ONIDLE.

/MO modifier to improve the program types to allow better control repeated
Cycle, effective value listed in the following "modifier" section,

/D is assigned the weekly run within days, the date of valid values:
MON, TUE, WED and THU FRI, SAT, SUN
1-31 and on or plan
The date) (month, wildcards "*" specify all
Date,

/M have specified month in a year, the default is the first day of the month,
Valid values: JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP and OCT, NOV, DEC, wildcard
"*" to specify all month,

/I idletime specified run a planned ONIDLE task before
To wait for the free time,
Valid range: 1 to 999 minutes,

Is assigned only to identify the plan/TN taskname name,

Time/TR taskrun specified in the plan the path of the running program
And the file name,
For example: C: \ Windows \ system32 \ calc exe

/ST starttime specified running time of the beginning of this task, time format
HH: mm (24 hours) for example comes to
At 2:30 PM, the default to the current time,

/RI with minute interval specify repetition interval, it cannot be applied to
Planned types: MINUTE, HOURLY,
ONSTART, ONLOGON ONIDLE,
Effective range: 1-599940 minutes,
If you specify the/ET or/DU, it will default to
10 minutes,

/ET endtime specify the end of the running task time,
Is time format HH: mm (24 hours)
For example name is known PM, this cannot be applied to
Plan types: ONSTART, ONLOGON ONIDLE,

/DU duration to specify the duration of the run this task,
Time format is HHHH: mm,
This does not apply to/ET and program types: ONSTART,
ONLOGON ONIDLE, if specified/RI,
The default is 1 hour,

/K at the end of the time or duration of termination of this task,
This does not apply to plan types: ONSTART,
ONLOGON ONIDLE, must specify/ET
Or/DU,

/SD startdate specified for the first time to run the
The date of the task, the format is yyyy/mm/dd,
Defaults to the current time, this does not apply to plan
Types: ONCE, ONSTART, ONLOGON,
ONIDLE.

/ED enddate specifying the date of the last day of this task to run,
Format is yyyy/mm/dd,
This does not apply to plan types: ONCE, ONSTART,
ONLOGON ONIDLE,

/IT/RU user login in this job runtime to rev.
With this task with interactive way,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related