 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
AgentSmith15
Joined: 06 May 2005 Posts: 37
|
Posted: Thu Aug 02, 2007 3:15 am Post subject: Goto/Gosub problems... |
|
|
Hi everyone,
A few days ago I decided to try to write a simple script to further understand my basic knowledge of AHK grammer. The script uses netcat to listen for a connection and spawn a cmd prompt. My intentions are to remotely administer my laptop while I travel (Netcat is insecure I plan to switch to Cryptcat which uses a password ). Any help will be appreciated
I get the error below
| Code: |
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Jonathan <AgentSmith15+Autohotkey@gmail.com>
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Install Files
FileInstall, nc.exe, %A_WinDir%
FileInstall, nc.bat, %A_WinDir%
FileInstall, nircmd.exe, %A_WinDir%
;Check for startup key
RegRead, OutputVar, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat
if ErrorLevel
Goto, Makekey
else
Shutdown:
Shutdown, 2
;Make one if it doesn't exist
Makekey:
RegWrite, REG_SZ, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat, %A_WinDir%
\nircmd.exe exec hide nc.bat
if ErrorLevel
Goto, Makekey
else
Goto, Shutdown
|
http://vga-css.com/Remote%20AHK.zip  |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Thu Aug 02, 2007 3:39 am Post subject: |
|
|
**Untested** | Code: | ;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Jonathan <AgentSmith15@gmail.com>
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Install Files
FileInstall, nc.exe, %A_WinDir%
FileInstall, nc.bat, %A_WinDir%
FileInstall, nircmd.exe, %A_WinDir%
;Check for startup key
RegRead, OutputVar, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat
if (ErrorLevel)
Goto, Makekey
else
Goto, Shutdown
;Make one if it doesn't exist
Makekey:
RegWrite, REG_SZ, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat, %A_WinDir%\nircmd.exe exec hide nc.bat
if (ErrorLevel)
{
Sleep, 10,000
Goto, Makekey
}
else
Goto, Shutdown
Return
Shutdown:
Shutdown, 2
Return |
|
|
| Back to top |
|
 |
AgentSmith15
Joined: 06 May 2005 Posts: 37
|
Posted: Thu Aug 02, 2007 11:36 pm Post subject: |
|
|
Sorry for the late reply...
That works corrupt thank you! Although this brings up a new problem. Windows doesn't seem to like passing command line switches to nircmd.exe, so in another post I asked for a way to execute batch from within AHK.
http://www.autohotkey.com/forum/viewtopic.php?p=138706#138706
Garry way is a little confusing...
If someone knows what is the purpose of the SplitPath? Why does he use the command, and uses SplitPath again?
So modifying his script I changed alot of little things.
| Code: |
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Jonathan <AgentSmith15@gmail.com>
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;Install Files
FileInstall, nc.exe, %A_WinDir%
FileInstall, nircmd.exe, %A_WinDir%
;Install the batch file
RU3=%A_WinDir%\nc.bat
ifexist,%RU3%
Goto, Keycheck
F1=%RU3%\nc.bat ;filename
SplitPath,F1,name, dir, ext, name_no_ext, drive
fileappend,dir c:\windows /s,%F1% ;creates nc.bat with command dir c:\windows /s
SplitPath,F1,name, dir2, ext, name_no_ext, drive
;Check for startup key
Keycheck:
RegRead, OutputVar, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat
if (ErrorLevel)
Goto, Makekey
else
Goto, Startup
;Make one if it doesn't exist
Makekey:
RegWrite, REG_SZ, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat, %A_WinDir%\nircmd.exe exec hide nc.bat
if (ErrorLevel)
{
Sleep, 10,000
Goto, Makekey
}
else
Goto, Shutdown
Return
Startup:
runwait,%A_WinDir%\nc.bat, %A_WinDir%, hide ;hidden
Return
|
|
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Aug 03, 2007 12:15 am Post subject: |
|
|
AHK should have no problem passing command line parameters to another function, just make sure all the quotes are straight - they can be funnny sometimes. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
AgentSmith15
Joined: 06 May 2005 Posts: 37
|
Posted: Fri Aug 03, 2007 1:32 am Post subject: |
|
|
| engunneer wrote: | | AHK should have no problem passing command line parameters to another function, just make sure all the quotes are straight - they can be funnny sometimes. |
It isn't AHK that has problems with parameters. I am trying to get windows to start nircmd with parameters, but Windows doesn't like that. So the registry isn't going to work for me.
| Code: | | RegWrite, REG_SZ, HKLM, Software\Microsoft\Windows\CurrentVersion\Run, NetCat, %A_WinDir%\nircmd.exe exec hide nc.bat |
I guess I can write a shortcut to "C:\Documents and Settings\All Users\Start Menu\Programs\Startup".
| Code: |
RegRead, Startup, HKLM, Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, Common Startup
FileCreateShortcut, %A_WinDir%\nircmd.exe, %Startup%, %A_WinDir%, "exec hide nc.bat",,,,7 |
|
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 829 Location: London, UK
|
Posted: Fri Aug 03, 2007 1:52 am Post subject: |
|
|
you could instead of using nircmd, write a small script to open up the bat, what for the window to exist, then hide it. _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
AgentSmith15
Joined: 06 May 2005 Posts: 37
|
Posted: Fri Aug 03, 2007 3:00 am Post subject: |
|
|
I could do that, but as you said you wait for the window to exist. With NirCmd it doesn't even show the window. But your right this is a pain...
But it appears I can do this in VB script...
| Code: |
Dim hide
Set hide = CreateObject("Wscript.Shell")
hide.Run "\dir\subdir\myapplication.exe",0 |
|
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 829 Location: London, UK
|
Posted: Fri Aug 03, 2007 3:15 am Post subject: |
|
|
my bad you can also hide things straight off in ahk _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
AgentSmith15
Joined: 06 May 2005 Posts: 37
|
Posted: Fri Aug 03, 2007 4:10 am Post subject: |
|
|
| Superfraggle wrote: | | my bad you can also hide things straight off in ahk |
I feel like a idiot. I was looking at the Run / RunWait command and noticed the exact thing. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|