Windows Services & Other Stuff

Developed or developing a new product in PureBasic? Tell the world about it.
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

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"
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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: Select all

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.

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 541
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: Services, Stuff, and Shellhook

Post by bbanelli »

Hi JHPJHP,

your Dropbox reports 429 generating too much traffic. :( Do you have alternative repository, GitHub or something similar?
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

Thank you very much JHP, it's excellent!
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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.

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
User avatar
Keya
Addict
Addict
Posts: 1865
Joined: Thu Jun 04, 2015 7:10 am

Re: Services, Stuff, and Shellhook

Post by Keya »

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>
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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)
Last edited by JHPJHP on Sun Jan 15, 2017 1:41 am, edited 1 time in total.

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

just one more question, how can i delete all restore points?
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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: Select all

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

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

Much Thanks

i add a procedure in your file

Code: Select all

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
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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

Delete all restore points:

Code: Select all

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

Code: Select all

DeleteRestorePoints("5,6,7")

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

Thank you very much, it's excellent!

Edit: but the server doesn't work
User avatar
Bisonte
Addict
Addict
Posts: 1163
Joined: Tue Oct 09, 2007 2:15 am

Re: Services, Stuff, and Shellhook

Post by Bisonte »

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.
PureBasic 5.73 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
JHPJHP
Addict
Addict
Posts: 1830
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Services, Stuff, and Shellhook

Post by JHPJHP »

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

STATUS: Mostly Unavailable :: Downloads moved to My PureBasic Stuff; free executables, access key required for source code.
_________________
boyoss
User
User
Posts: 74
Joined: Fri Feb 05, 2016 10:11 am

Re: Services, Stuff, and Shellhook

Post by boyoss »

Thank you JHP for your wonderfull work


Envoyé de mon iPhone en utilisant Tapatalk
Post Reply