forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


VDS SERVICES DEMO(start/stop/pause services from VDS) !!

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Jul 25, 2003 5:08 pm    Post subject: VDS SERVICES DEMO(start/stop/pause services from VDS) !! Reply with quote

VDS SERVICES DEMO(start/stop services from VDS):

Quick Info - Control window Services.
VDS version - VDS 5.x +
Windows version - Win 2k/NT/XP
Not compatible - Win9x
Non-VDS/Non System dll - No.
API - Yes.
Tested on - Win XP.
Difficulty Rating - Beginner/Intermediate/Advanced


This is a small script which tries to show you how to control services from your VDS application using API.
For simplicity of beginners the main code is kept in the include file and custom commands which are English kanguage like are created.

In your script you should add the following line at the top
#INCLUDE Services.fil
and make sure that the file is in the same directory as your .dsc file

FUNCTIONS:
Code:
@Service(Start,computername,%A) - Starts the service %A on the computer "computername"

@Service(Stop,computername,%A) - Stops the service %A on the computer "computername"

@Service(Pause,computername,%A) - Pause the service %A on the computer "computername"

@Service(Continue,computername,%A) - Resumes the paused service %A on the computer "computername"

@Service(GetStatus,computername,%A) - Get the current status of the service %A.

where %A is the name of a valid installed service.
You can set computername to 0 (zero) for use on a local computer.

Each function will return - success/0 on succes.
If a function fails it will return - an error name - in English !
You need to have administrative privileges for the given function else a "Access Denied" error is returned.

You can get the entire package with help file from here http://www.vdsworld.com/index.php?page=download&fileid=301
Enjoy !

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension


Last edited by CodeScript on Thu Jul 31, 2003 6:08 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1562

PostPosted: Fri Jul 25, 2003 5:13 pm    Post subject: Reply with quote

You can post a url without the " " and it automatically hyperlinks it for you. Just start it with http:// and it links automatically.
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Jul 25, 2003 5:20 pm    Post subject: Reply with quote

Sorry prakash - the qoutes are intentional else - geocities wont allow the refferer and U get a 404.
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1562

PostPosted: Fri Jul 25, 2003 5:25 pm    Post subject: Reply with quote

Didn't know Sad that's pretty terrible geocities does that but understable since alot of people host warez, etc on free services Sad
Back to top
View user's profile Send private message
Hortalonus
Valued Contributor
Valued Contributor


Joined: 15 Mar 2002
Posts: 344
Location: Western USA

PostPosted: Fri Jul 25, 2003 6:16 pm    Post subject: Reply with quote

Wow! Nice example CodeScript... I have always just used:
Code:
RUNH NET START %%servicename
RUNH NET STOP %%servicename

I like your method much better since you are directly interacting with the Service Manager. Good job, my friend! Thumbs Up

_________________
"ah, come take my hand... we're ridin' out tonight to face the promised land"
Get a free iPod mp3 player...
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Jul 25, 2003 9:01 pm    Post subject: Reply with quote

I've always worried about using the NET way... such as if the file was
not found... I had a folder called "NET" in the same directory as my
application once and it kept opening that.

CodeScript, have you signed up for an author account at VDSWORLD?
Really, please do. It would make it a lot easier for everyone. You can
link directly to your upload, and you get some statistics, etc. Very Happy

Plus, you now will have your file listed with the ability for comments and
ratings! Wink

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Jul 26, 2003 4:51 am    Post subject: Reply with quote

For people who want to use the NET command these are the options:

Code:
NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
      HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |
      SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]
I knew only about NET START and STOP Embarassed
e.g NET STOP Themes

Also the START command in my script may not always return the correct error. To improve its accuracy you can get the error number at each step in the subroutine and put them together. Even then it may not be always accurate as microsoft says.

The only advantage with API way I see is it appeared much more stable to me compared to the NET commands. I have not tested it in a network environment though.

You can convert all the commands available using NET to API ones as per your requirments if U want
_______________________________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Jul 26, 2003 12:55 pm    Post subject: Reply with quote

Some Additions:
I have updated the help file with common local service names and their descriptions. If U want U may consider redownloading it.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Hortalonus
Valued Contributor
Valued Contributor


Joined: 15 Mar 2002
Posts: 344
Location: Western USA

PostPosted: Fri Sep 26, 2003 8:59 pm    Post subject: Reply with quote

Hey CodeScript, I wanted to thank you for this excellent example. I have used it much. Quick question... do you know why this works?
Code:
%%result = @SERVICE(START,0,"ServiceName")

but this does not work.
Code:
%%serviceName = "ServiceName"
%%result = @SERVICE(START,0,%%serviceName)

And yet this does work.
Code:
%%serviceName = "ServiceName"
%%serviceStatus = @SERVICE(GetStatus,0,%%serviceName)

Confused Confused Confused
It would be nice if I didn't have to hard code the service name into the start/stop functions.

_________________
"ah, come take my hand... we're ridin' out tonight to face the promised land"
Get a free iPod mp3 player...
Back to top
View user's profile Send private message Send e-mail
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Sep 27, 2003 6:40 am    Post subject: Reply with quote

Hi Hortalonus

This is from the example I provided with it:

Code:
%A = @DLGTEXT(EDIT1)
INFO @Service(Start,0,%A)


%A = Schedule
%B = @Service(Start,0,%A).


Both work fine here.
As you can see the service name is not hardcoded.

1.Try using local variables i.e from %A to %Z rather than
%%Service and also see what happens with above example starting the windows task scheduler.
2.Also don't use quotes e.g. "Schedule" I don't think you are doing that anyway.
3.Another possibilty which is more likely is that you have used %%serviceName
variable somewhere else in your script or include files or DSU and contents get overwritten.
Try changing the variable to something else/search your project for a dupe of the same variable somewhere else.
4.Display names and actual names of services are different.
Sometimes they are very similar and using dislplay name gives inconsistent results.
So find out the correct name of the service from the service manager.


If it still doesnot work try the Services.fil in this:
http://codescript.vdsworld.com/VDS5src/VDSServiceProject.zip
Some problems present in the initial version were fixed I think in this. Still it may not work
properly in network environment.Reason being I don't have access to one.

Hope this helps.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Wed Oct 01, 2003 5:07 pm    Post subject: Reply with quote

Hortalonus was the problem resolved ?
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Hortalonus
Valued Contributor
Valued Contributor


Joined: 15 Mar 2002
Posts: 344
Location: Western USA

PostPosted: Wed Oct 01, 2003 7:14 pm    Post subject: Reply with quote

I am sorry for not responding... I did not work the first two days of this week. And yes, changing the variable name from %%serviceName to %S did the trick. Although I don't see why it would. Confused

Thank you for your help CodeScript! Very Happy

_________________
"ah, come take my hand... we're ridin' out tonight to face the promised land"
Get a free iPod mp3 player...
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group