AutoHotkey Community

It is currently May 27th, 2012, 6:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: September 10th, 2004, 7:55 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
posting the relevant sections from that script would help! :)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2004, 8:28 am 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
From my vpn connecting script?

Here is the basis of it:
Code:
Loop
{
  Loop, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces, 1, 1
  {
     RegRead, value
     if a_LoopRegName = DhcpDomain
     {
      domain = %value%
    }
  }
  if domain <> workdomain.com
  {
    IfNotExist, \\computeratoffice\c\
    {
      RunWait, VPNClient.exe
    }
  }
  Sleep, 100
}

The full script is over 380 lines long. With tooltips, traytips, changing icon in the system tray for when I am connected vs. not connected, etc...

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2004, 1:11 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
i thought maybe u've converted the service creation procedure to ahk script... but its ok.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2004, 6:52 pm 
Offline

Joined: September 2nd, 2004, 1:08 am
Posts: 124
Location: Sunnyvale
beardboy wrote:
Sorry I never posted a tutorial on how to get this setup correctly.

First I copy srvany.exe into the system32 folder.


I did not have to do this, it ran fine straight from my Program files\Resource Kit directory. Using XP SP1. As long as the full path to srvany is in the ImagePath registry key, it should work.

_________________
I am he of whom he speaks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2004, 7:46 am 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
Atomhrt wrote:
I did not have to do this, it ran fine straight from my Program files\Resource Kit directory. Using XP SP1. As long as the full path to srvany is in the ImagePath registry key, it should work.

Correct, I just put that on there for people that might download it off of the web and not install it with Resource Kit, it just needs to be in a folder that is specified in the path. Or a direct path needs to be specified.

Rajat wrote:
i thought maybe u've converted the service creation procedure to ahk script... but its ok.

Nope sorry, it was just easier to use sc.exe and reg.exe to quickly add a service.

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 9th, 2006, 11:23 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
How do I use your srvany.exe utility? When I open srvany.exe the dos window just quickly flashes. I need to use that utility to turn an application into a service.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 12:36 am 
Code:
cmd /k srvany.exe
Check its outcome.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 2:00 am 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
First you need to create a service using SC.exe
Code:
sc.exe create MyService binPath= c:\windows\system32\srvany.exe type= own type= interact start= auto

Then after you create the service you need to modify the program you want srvany to start and stop for you using REG.exe
Code:
reg.exe add HKLM\system\currentcontrolset\services\MyService\Parameters\Application=notepad.exe

The only things you need to change are the service name if you want it different "MyService", the program you want to run "notepad.exe", and the location of srvany.exe if you have it located somewhere else.

Let me know if you have any more questions.

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 10th, 2006, 5:02 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Is there a way to configure the service to run at a particular time instead of running when a user logs into the Windows 2003 system? Thank you.

Let me just summarize my problem: I have programmed my scripts and compiled them into executables. I then used Windows Scheduler to schedule my execuatbales for a particualr time. Everything worked great until I tried to run my scheduled tasks while my screen was locked. I am hoping this issue will be resolved by making my scripts into services instead of appliactions. What are your thoughts on this issue? Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 5:28 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
My suggestion would be to have your compiled exe's just run your needs at a particular time. Setup a compiled exe that only runs what you want to run at specific times (within your ahk code, if time = this time run this...). Then you have that exe started as a service, it will always be running even if you aren't logged into the computer.

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 10th, 2006, 6:17 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Do you have any example code for the function if Time = ?

Also, I am having trouble starting my test service. Heres what I did:
1) I created a quick test script that has the following code:

Run, Notepad.exe
WinWait, Untitled - Notepad,
IfWinNotActive, Untitled - Notepad, , WinActivate, Untitled - Notepad,
WinWaitActive, Untitled - Notepad,
Send, test
Sleep, 100

2) I compiled the script called notepad2.exe and copied it along with the sc.exe and sryan.exe into the /system32 directory

3) I ran the following commands in the command line:

sc.exe create Notepad2 binPath= c:\windows\system32\srvany.exe type= own type= interact start= auto
reg.exe add HKLM\system\currentcontrolset\services\Notepad2\Parameters\Application=notepad2.exe

4) I tried to manually start my service and I got the following error message:

The Notepad2 service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, Performance Lof and Alerts service.

Do you know how I can prevent the service from automatically stopping? Thank you so much for all of your help!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 6:22 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
Is your windows directory "c:\windows" or "c:\winnt"?
The other thing is if you are running XP, XP comes with a newer version of Reg, which might have setup the registry key wrong. I suggest putting the reg.exe that you downloaded here and put it in a specific folder on your computer then runing the reg.exe command you listed from that directory.

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
 Post subject: I use Winnt
PostPosted: February 10th, 2006, 6:32 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
I use Winnt put I did remember to edit that before I hit enter on the command line.

Let me make sure I understand what you are saying. Do you want me to do the following:

Step 1) Take the reg.exe that I downloaded from your Utilities.zip directory and copy it to C:\Winnt\System32

Step 2) Take the reg.exe that I downloaded from your Utilities.zip directory and copy it to a directory of my choice

Step 3) Double click and run the reg.exe from Step 2

Thank you so much for all the help.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 8:22 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
Try this for me instead.

sc.exe start Notepad2

And let me know what it says.

thanks,
beardboy


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2006, 8:26 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
This is what it says:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>sc.exe start Notepad2

SERVICE_NAME: Notepad2
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 3 STOP_PENDING
(STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 3492
FLAGS :



Thank you so much for all the help.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group