Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Some Utilities


  • Please log in to reply
34 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
posting the relevant sections from that script would help! :)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
From my vpn connecting script?

Here is the basis of it:
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

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i thought maybe u've converted the service creation procedure to ahk script... but its ok.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Atomhrt
  • Members
  • 124 posts
  • Last active: Nov 13 2006 09:18 PM
  • Joined: 02 Sep 2004

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!

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004

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.

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

arabinow
  • Members
  • 19 posts
  • Last active: Feb 28 2006 01:37 PM
  • Joined: 09 Feb 2006
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.

BoBo
  • Guests
  • Last active:
  • Joined: --
cmd /k srvany.exe
Check its outcome.

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
First you need to create a service using SC.exe
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
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

arabinow
  • Members
  • 19 posts
  • Last active: Feb 28 2006 01:37 PM
  • Joined: 09 Feb 2006
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.

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
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

arabinow
  • Members
  • 19 posts
  • Last active: Feb 28 2006 01:37 PM
  • Joined: 09 Feb 2006
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!

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
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

arabinow
  • Members
  • 19 posts
  • Last active: Feb 28 2006 01:37 PM
  • Joined: 09 Feb 2006
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.

beardboy
  • Members
  • 443 posts
  • Last active: May 27 2017 08:41 AM
  • Joined: 02 Mar 2004
Try this for me instead.

sc.exe start Notepad2

And let me know what it says.

thanks,
beardboy

arabinow
  • Members
  • 19 posts
  • Last active: Feb 28 2006 01:37 PM
  • Joined: 09 Feb 2006
This is what it says:

Microsoft Windows XP [Version 5.1.2600]
© 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.