PureBasic Forum
http://forums.purebasic.com/english/

Windows Services & Other Stuff
http://forums.purebasic.com/english/viewtopic.php?f=12&t=60881
Page 4 of 7

Author:  boyoss [ Thu Jan 12, 2017 9:27 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Thank you very much for your help, but still when i restart the computer, all services restart.
I need a command to do the "net stop"

Author:  JHPJHP [ Thu Jan 12, 2017 9:49 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Updated the SERVICES section of the package.
- added Constants
- fixed Structures, Procedures
- renamed 1 example
-- CreateService_x86.pb to CreateService.pb

NB*: With the above changes the CreateService.pb example now works in both the 32 bit and 64 bit IDE (compiler).

---------------------------------------------------------------------

Hi boyoss,

After stopping a service you need to disable it, if you don't want the service to restart when the computer reboots.
- setting it to Manual (#SERVICE_DEMAND_START) may not stop the OS from restarting it
Code:
ServiceStop(ServiceName)
ServiceStartup(ServiceName, #SERVICE_DISABLED)

NB*: The NET Stop command is the same as the ServiceStop Procedure, and wouldn't prevent the service from restarting when the computer rebooted.

Author:  bbanelli [ Thu Jan 12, 2017 10:56 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi JHPJHP,

your Dropbox reports 429 generating too much traffic. :( Do you have alternative repository, GitHub or something similar?

Author:  boyoss [ Thu Jan 12, 2017 11:10 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Thank you very much JHP, it's excellent!

Author:  JHPJHP [ Fri Jan 13, 2017 1:24 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi bbanelli,
Dropbox wrote:
Error (429)
This account's links are generating too much traffic and have been temporarily disabled!

Thank you for the heads-up. Unfortunately, I have no other repository setup. I will check back tomorrow, if there is still a problem I will look into another means of distributing the files.

---------------------------------------------------------------

Hi boyoss,

You're welcome, I'm glad it worked for you.

Author:  Keya [ Fri Jan 13, 2017 1:49 am ]
Post subject:  Re: Services, Stuff, and Shellhook

in regards to a stopped service automatically restarting, when you use Control Panel -> Services and right-click Stop a service it doesn't automatically restart, so I wonder if there's a #DONTRESTART kinda flag that can be used, or if it temporarily Disables it for a few seconds!? no idea sorry </useful contribution>

Author:  JHPJHP [ Sat Jan 14, 2017 12:46 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Updated the Stuff folder:
- added 1 include
-- PS_RestorePoints.pbi
- added 1 example
-- PS_CreateShowDelete.pb

Using PowerShell the following Procedures have been created to access the Windows System Restore Points.
- PS_RestorePoints.pbi (CreateRestorePoint, ListRestorePoints, GetExecutionPolicy, SetExecutionPolicy, DeleteRestorePoints)

Author:  boyoss [ Sat Jan 14, 2017 6:41 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

just one more question, how can i delete all restore points?

Author:  JHPJHP [ Sat Jan 14, 2017 11:53 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi boyoss,

The simplest way using the existing IncludeFile is to iterate through the sequence numbers.
- replace the code in the example PS_CreateShowDelete.pb with the following script:
Code:
IncludeFile "PS_RestorePoints.pbi"

PS_Description.s = "test_2017"
CreateRestorePoint(PS_Description)
RestorePoints.s = ListRestorePoints()
Debug RestorePoints : #DELETE_ALL = #True

If #DELETE_ALL
  Define.s dwEventType

  For rtnCount = 1 To CountString(RestorePoints, #LF$)
    dwEventType = StringField(RestorePoints, rtnCount, #LF$)
    nSearch1 = FindString(dwEventType, "BEGIN_SYSTEM")
    nSearch2 = FindString(dwEventType, "END_SYSTEM")
    nSearch3 = FindString(dwEventType, "BEGIN_NESTED")
    nSearch4 = FindString(dwEventType, "END_NESTED")

    Select #True
      Case Bool(nSearch1), Bool(nSearch2), Bool(nSearch3), Bool(nSearch4)
        PS_Sequence = Val(Mid(dwEventType, 50, 22))
        DeleteRestorePoint(PS_Sequence)
    EndSelect
  Next
Else
  intStart = FindString(RestorePoints, PS_Description)

  If intStart
    intStart + Len(PS_Description) + 1
    intLength = FindString(RestorePoints, "BEGIN_SYSTEM", intStart) - intStart
    PS_Sequence = Val(Mid(RestorePoints, intStart, intLength))
    DeleteRestorePoint(PS_Sequence)
  EndIf
EndIf

NB*: Only 1 restore point can be created every 24 hours using the PowerShell method... See: Checkpoint-Computer

Author:  boyoss [ Sun Jan 15, 2017 12:02 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Much Thanks

i add a procedure in your file

Code:
Procedure DeleteAllRestorePoint()
   Define.s dwEventType
   Define.s RestorePoints
   
   RestorePoints.s = ListRestorePoints()

   For rtnCount = 1 To CountString(RestorePoints, #LF$)
      dwEventType = StringField(RestorePoints, rtnCount, #LF$)
      nSearch1 = FindString(dwEventType, "BEGIN_SYSTEM")
      nSearch2 = FindString(dwEventType, "END_SYSTEM")
      nSearch3 = FindString(dwEventType, "BEGIN_NESTED")
      nSearch4 = FindString(dwEventType, "END_NESTED")
      
      Select #True
         Case Bool(nSearch1), Bool(nSearch2), Bool(nSearch3), Bool(nSearch4)
            PS_Sequence = Val(Mid(dwEventType, 50, 22))
            DeleteRestorePoint(PS_Sequence)
      EndSelect
   Next
EndProcedure

Author:  JHPJHP [ Sun Jan 15, 2017 1:22 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Updated Stuff\RestorePoints\PS_RestorePoints.pbi
- added 1 Procedure: DeleteRestorePoints(RestorePoints.s)

Delete all restore points:
Code:
RestorePoints.s = ListRestorePoints()
DeleteRestorePoints(RestorePoints)

Delete known restore points:
Code:
DeleteRestorePoints("5,6,7")

Author:  boyoss [ Sun Jan 15, 2017 6:26 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Thank you very much, it's excellent!

Edit: but the server doesn't work

Author:  Bisonte [ Sun Jan 15, 2017 10:47 am ]
Post subject:  Re: Services, Stuff, and Shellhook

bbanelli wrote:
Hi JHPJHP,

your Dropbox reports 429 generating too much traffic. :(


I have the same problem with my dropbox account, nearly two years.
I can change this state only, if I change to a "Premium" account....

I think you have now the same problem JHPJHP.

Author:  JHPJHP [ Wed Jan 18, 2017 6:50 pm ]
Post subject:  Re: Services, Stuff, and Shellhook

Hi bbanelli, Bisonte,

I've updated the download links, replacing Dropbox with OneDrive.

------------------------------------------------------

Updated:
- added 1 example to the Stuff folder
-- OtherStuff\FileSecurity.pb

This example adds explicit permissions (removes inheritance) using a variety of methods.

I recently read this post about problems setting permissions / renaming a file located in the System32 folder, and wanted to see if a modified version of the script I used for Network Share Management Functions resolved this.

NOTE (tested in Windows 10):
- changing permissions in the System32 folder requires the 64bit IDE, otherwise permissions are changed to the matching file in the SysWOW64 folder
-- must set Request Administrator mode for Windows Vista and above from Compiler Options

NB*: Request Administrator mode for Windows Vista and above is not required for files located outside a protected folder (64bit IDE not required outside the System32 folder).

Author:  boyoss [ Thu Jan 19, 2017 1:10 am ]
Post subject:  Re: Services, Stuff, and Shellhook

Thank you JHP for your wonderfull work


Envoyé de mon iPhone en utilisant Tapatalk

Page 4 of 7 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/