It is currently Wed Jun 26, 2019 8:52 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Fri Jan 27, 2017 1:24 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Hi boyoss,

You're very much welcome.

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

Updated the Stuff folder:
- PrinterStuff\
-- PrinterStuff.pbi, AddMonitor.pb, DeleteMonitor.pb, AddPort.pb, DeletePort.pb, AddDriver.pb, UploadDriver.pb, InstallDriver.pb, DeleteDriver.pb
-- AddPrinter.pb, DeletePrinter.pb, SetSecurity.pb
-- MS_PS_CD_V3\... (required by AddDriver.pb)
-- MS_PS_CD_V4\... (required by UploadDriver.pb)

Based on a question asked here: Adding Port, Driver, Printer in Windows.

*** Tested in Windows 10 ***
- included driver files were taken from the Windows 10 OS

Instructions (order of execution is important):
- Setup
-- 1. AddMonitor.pb
-- 2. AddPort.pb
-- 3. AddDriver.pb: only needed if manually adding driver files
-- 3. UploadDriver.pb: only needed if driver is not in the Driver Repository
-- 3. InstallDriver.pb: only needed if driver is not already installed (not to be confused with an installed printer)
-- 4. AddPrinter.pb
-- 5. SetSecurity.pb: only needed if you want to restrict access, default security is ok for standard printing
- Cleanup
-- 1. DeletePrinter.pb
-- 2. DeleteDriver.pb: removes the installed driver (registry settings) not the actual files
-- 3. DeletePort.pb
-- 4. DeleteMonitor.pb

NOTE:
- Driver Repository: C:\WINDOWS\System32\DriverStore\FileRepository\...
- Printer Driver Directory: C:\Windows\System32\spool\drivers\x64\
-- identified using the Procedure GetDriverDirectory
- Important Registry Settings:
-- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\...
-- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\...

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Fri Jan 27, 2017 2:59 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Updated Stuff\PrinterStuff\
- renamed 2 examples
-- UploadDriver.pb to UploadDriverPackage.pb
-- InstallDriver.pb to InstallDriverPackage.pb
- added 6 examples
-- GetDriver.pb
-- DeleteDriverPackage.pb
-- EnumerateMonitors.pb, EnumeratePorts.pb, EnumeratePrinters.pb, EnumerateDrivers.pb

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Sat Jan 28, 2017 9:58 pm 
Offline
User
User

Joined: Fri Feb 05, 2016 10:11 am
Posts: 73
Hi jhp thanks for your wonderful work!

Is it possible to create a service for an non-service exe?
I saw this software http://nssm.cc is doing it, but is it possible to do it with pb?


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Sun Jan 29, 2017 9:47 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Hi boyoss,

Sorry, but there are too many questions floating around concerning your intentions, for me to feel comfortable helping you any further.

Either way its time to rethink your approach; you are either trying to program an ill-conceived idea, or an ineffectual virus.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Sun Jan 29, 2017 11:55 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
Hi JHPJHP
boyoss wrote this:
Quote:
i need this code for my program, i build a program for an office where i want to block internet on the computers, so the secretary will work and not wasting time in facebook etc.
for this i need to delete the restore points and create a new one, so they can't rool back the changements i made.
i can use a software that doing the work, but it's easyer for me to do all the work in my software.
Deleting restore points on a commercial used computer :evil:

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Mon Jan 30, 2017 7:21 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Updated Stuff\
- renamed 2 examples
-- RestorePoints\PS_RestorePoints.pbi to PowerShell\RestorePoints\RestorePoints.pbi
-- RestorePoints\PS_CreateShowDelete.pb.pb to PowerShell\RestorePoints\CreateShowDelete.pb.pb
- added 1 example
-- PowerShell\SendHtmlEmail.pb

SendHtmlEmail.pb was based on a question asked here: How to use html in body of PB mail?

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Thu Feb 02, 2017 11:56 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Jun 21, 2011 10:39 am
Posts: 326
Hi JHPJHP. When I tested the printer functions before - AddMonitor > AddPort > AddDriver > AddPrinter - they all worked.

But testing them again now AddDriver is giving a windows error 3014 (The printer driver is known to harm the system) and this message:
Quote:
Driver Installation Error
Windows can't install the Miscrosoft PS Class Driver print driver. To obtain a driver that is compatible with the version of Windows your are running, contact the manufacturer.

I deleted all the monitors and ports and removed all the printers that I created - registry too - and tried again. But still getting the same error.

Any ideas why this is happening?

Windows 8.1 - tried with various versions of PB x86 and x64 Unicode & ASCII - Your original code unedited.


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Thu Feb 02, 2017 4:21 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Hi coder14,

Make sure you have the latest version of PrinterStuff, there have been some changes.

Is this the same computer where it worked previously?
- if so, I cannot tell you what has changed on your system
Are you using the drivers I provided, or providing you own?
- depending on the answer to the first question... the drivers I provided came from Windows 10 and may not be compatible

It also sounds like you're using a Version-3 driver in a newer OS; you will get better compatibility using a Version-4 driver.
- instead of AddDriver.pb use InstallDriver.pb (may need to execute UploadDriver.pb first)

Creating your own driver package (Version-4):
- install the printer manually
- goto HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-4\[PRINTER]
- find the String Value: InfPath (used in the example InstallDriverPackage.pb)
- copy the files from InfPath to a new folder (used in the example UploadDriverPackage.pb)
- remove the printer you manually created

NB*: I created the Version-3 driver package from the following folder in Windows 10: C:\Windows\System32\spool\drivers\x64\3\

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Mon Feb 06, 2017 3:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Jun 21, 2011 10:39 am
Posts: 326
Thank you JHPJHP. I'm still working it out.


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Wed Feb 08, 2017 9:47 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Updated the Stuff folder:
- AnimateGIF\AnimateGIF.pb

The Procedure AnimateGIF includes five parameters:
- GIFFolder: folder of GIF files [ mandatory ]
- GIFFile: animated GIF [ mandatory ]
- DisposalMethod: how cumulative layers are handled [ optional: default 0 ]
- DelayTime: delay between each frame [ optional: default -1 ]
- LoopAnimation: enable/disable continuous looping [ optional: default #True ]

The example is based on code found here with additional support from here.

NB*: You may find the code interesting if you are curious about working with Structures that include Bit fields.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Feb 13, 2017 4:24 am, edited 8 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Thu Feb 09, 2017 3:14 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Jun 21, 2011 10:39 am
Posts: 326
Hello JHPJHP. I've been struggling with InstallDriver - it just doesn't work. The separate functions work but I don't know how to get the individual driver files (.DLL, .PPD, .NTF) for a specific printer. If I download a Xerox or HP driver I only get an .INF file - maybe to be used with InstallDriver.

The generic PS files (PS5UI.DLL, PSCRIPT5.DLL, PSCRIPT.NTF, MSXPSINC.PPD) work but outputs only mono prints - no color.

Which is the better way? MSDN recommends InstallPrinterDriverFromPackage but that is not backward compatible with XP. I think that the AddMonitor/AddPort/AddDriver/AddPrinter combination is still compatible with Windows 8 & 10 but I can't find the files.

Can you please point me right? :?


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Thu Feb 09, 2017 3:33 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Hi coder14,

Version 3 drivers are not guaranteed to be compatible with Windows 7, 8, 10.

Use both solutions: OSVersion()
- install the printer manually in Windows XP... create a Version 3 driver package from the installed files
- install the printer manually in Windows 10... create a Version 4 driver package from the installed files

NB*: Refer to my previous post on this topic, for instructions on creating a driver package.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Feb 13, 2017 4:55 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Sat Feb 11, 2017 10:47 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Updated the Stuff folder:
- AnimateGIF\SplitGIF.pb

The Procedure SplitGIF includes three parameters:
- GIFFile: file to split [ mandatory ]
- ResetDisposal: removes all disposal settings [ optional: default #False ]
- ResetDelay: removes all delay times [ optional: default #False ]

Included with the examples are two animated GIFs:
- \images\Banana.gif
- \images\BugsBunny.gif

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Feb 13, 2017 4:24 am, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Sun Feb 12, 2017 10:31 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1571
Updated:
- modified 2 examples
-- Stuff\AnimateGIF\AnimateGIF.pb
-- Stuff\AnimateGIF\SplitGIF.pb

Optimized the example AnimateGIF.pb.
- updated the Application Extension block based on data from Netscape Looping Application Extension

Fixed an issue in the example SplitGIF.pb that caused color distortions when the file included a local color table.
- based on information from What's In A GIF - Bit by Byte

** Tested both examples against a variety of GIF files without any noticable problems.

Cumulative Layers:
- change the DisposalMethod parameter if an animation isn't layering correctly

NB*: I've noticed with some files, setting a delay time of 1 or 2 will transition the frames faster then a setting of 0.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Services, Stuff, and Shellhook
PostPosted: Mon Feb 13, 2017 4:16 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Jun 21, 2011 10:39 am
Posts: 326
JHPJHP wrote:
Hi coder14,

Make sure you have the latest version of PrinterStuff, there have been some changes.

Is this the same computer where it worked previously?
- if so, I cannot tell you what has changed on your system
Are you using the drivers I provided, or providing you own?
- depending on the answer to the first question... the drivers I provided came from Windows 10 and may not be compatible

It also sounds like you're using a Version-3 driver in a newer OS; you will get better compatibility using a Version-4 driver.
- instead of AddDriver.pb use InstallDriver.pb (may need to execute UploadDriver.pb first)

Creating your own driver package (Version-4):
- install the printer manually
- goto HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-4\[PRINTER]
- find the String Value: InfPath (used in the example InstallDriverPackage.pb)
- copy the files from InfPath to a new folder (used in the example UploadDriverPackage.pb)
- remove the printer you manually created

NB*: I created the Version-3 driver package from the following folder in Windows 10: C:\Windows\System32\spool\drivers\x64\3\

Hi JHPJHP. For compatibility with older Windows I'm sticking with V3 drivers. I copied 32bit and 64 bit drivers and the installer works on XP(x86), 7(x86), 8.1(x64) and 10(x64).

Uninstalling fails to remove the monitor and driver unless we reboot after deleting the printer and port. I tried restarting the spooler and that works too (but not on XP). Is there a way to do this through code (net start/stop spooler)?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye