Page 1 of 2 12>
Topic Options
#133155 - 2005-01-31 12:36 PM Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Hi all,

Can any body tell me a way of running a kix script on a remote machine? In order that it executes commands on that machine? Is this possible?

Ie User 1 connects to \\computer1\c$ runs scipt that executes kix commands on \\computer1....

Is this poss via script?

Regards

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133156 - 2005-01-31 12:49 PM Re: Running a remote kix script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Sure. You can either schedule the task or use WMI.

Search the UDF forum for examples of both methods.

Top
#133157 - 2005-01-31 01:39 PM Re: Running a remote kix script
Anonymous
Unregistered


Richard,

Thanks for the reply, I have found a UDF ONEAWEEK() but this does not meet my needs as I need to be able to run a script remotely in real time. This will be done manually and not during logon. And will need to be runs several times a day..

Steve.

Top
#133158 - 2005-01-31 02:08 PM Re: Running a remote kix script
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
check out PSEXEC from sysinternals. works well for us here.
_________________________
Eric

Top
#133159 - 2005-01-31 02:19 PM Re: Running a remote kix script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
What's wrong with RemoteExec()?
Top
#133160 - 2005-01-31 02:24 PM Re: Running a remote kix script
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
... what do you try to accomplish?
_________________________



Top
#133161 - 2005-01-31 02:57 PM Re: Running a remote kix script
Anonymous
Unregistered


Hi Jochen,

I have already scripted a rather primative system that allows my Teachers to disable/enable the Internet via a simple form. The form just copies (for disable) deletes (for enable) a 0 kb file onto the netlogon shares. I then have a second script (runs after logon) that looks for file and if exists overwrites 'proxyserver' HKCU key with "", so when users try to run their Iexplore icon, (actually a kix script that checks state of proxyserver) they get a message 'your internet is disabled'.

I wanted to extend this further by allowing teachers to disable invidual machines, I thought perhaps I would create a form that listens for input (computer name variable) then goes off and runs a script on that remote machine, and over writes 'proxyserver'.

Steve.

Top
#133162 - 2005-01-31 03:13 PM Re: Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
I have tried to use the UDF in the following way, but get the error. 'Failed to find open script' when I get to this part of the script, Code:
 $Connect = GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$computer+'/root/cimv2:Win32_Process') 



The following is what im using to test. Code:
 FUNCTION RemoteExec($command, optional $computer)
dim $Connect, $Process
if not $computer
$computer='.'
endif
if instr($computer,'\')
$computer=substr($computer,instrrev($computer,'\')+1)
endif
$Connect = GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$computer+'/root/cimv2:Win32_Process')
$Process = $Connect.Create($Command)
exit @error
ENDFUNCTION


RemoteExec('kix32 c:\windows\hiddrv.kix', $ITadmin)



Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133163 - 2005-01-31 03:23 PM Re: Running a remote kix script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try fully qualifying the path to kix32.exe

You will probably want to kill any active IE processes as well, to ensure that it reloads the settings from the registry.

To be honest, you should really be using a proxy or something like WebSense to manage Internet access. Fiddling about at the client end is a poor solution.

Top
#133164 - 2005-01-31 03:36 PM Re: Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Hi Richard;
Quote:

To be honest, you should really be using a proxy or something like WebSense to manage Internet access


I work in a school!!! Money is really tight! Besides is there a product out there that can give me this kind of flexibility? Ive used Imperata for class room management and it has more holes than Swiss Cheese!

Also I have been using this system (for some time) and I have not had any issue with it, in fact the Teachers are over the moon with it! But hey if you can recommend any software that allows you to disable internet access by room/computer/session then Ill certainly look at it. Does websense do this?

PS I work in a school...
MONEY IS REALLY TIGHT!
Regards

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133165 - 2005-01-31 04:21 PM Re: Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Tried the following as per Richards suggestion..
Code:
RemoteExec('%windir%\kix32 c:\%windir%\hiddrv.kix', $ITadmin)



Im still getting 'failed to find/open script' It is running the script though (im using /d).

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133166 - 2005-01-31 04:23 PM Re: Running a remote kix script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

But hey if you can recommend any software that allows you to disable internet access by room/computer/session then Ill certainly look at it. Does websense do this?




Yes.

Quote:

PS I work in a school...
MONEY IS REALLY TIGHT




Whoa, no need to shout, I ain't deaf yet.

Websense is very expensive, and very complicated so it may not suit you.

Doesn't your local education authority have guidelines or best practices for providing internet access to pupils? I would have thought that would be the best place to look for direction. You should certainly ensure that you are complying with any minimum level of monitoring and control of access.

What you've got now may suit your needs but kids are often surprisingly devious and tricky and the only way to ensure that they cannot bypass the security is to take access control away from the client and manage it on the router / firewall / proxy.

The cheapest solution is to use a proxy, and only allow the proxy computer to access the Internet directly. You then manage client access on the proxy. This works very well in most situations. It only falls down when you need to provide access to protocols which are not supported by the proxy.

Top
#133167 - 2005-01-31 04:36 PM Re: Running a remote kix script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The parm "c:\%windir%\hiddrv.kix" is wrong. Since %windir% includes the drive letter,
"c:\%windir%\hiddrv.kix"
would expand to:
"c:\C:\Windows\hiddrv.kix"
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133168 - 2005-01-31 04:37 PM Re: Running a remote kix script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
RemoteExec('%windir%\kix32 %windir%\hiddrv.kix', $ITadmin)

however, the vars will be evaluated before it is sent

so
copy $folder+'\kix32.exe' $itadmin+'\c$$\temp'
copy $folder+'\hiddrv.kix' $itadmin+'\c$$\temp'
RemoteExec('c:\temp\kix32 c:\temp\hiddrv.kix', $ITadmin)
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#133169 - 2005-01-31 05:02 PM Re: Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Richard thanks for reply,

Im afraid a proxy isnt the solution, we do have a proxy server what is controlled off site. And we do have a facility to monitor what content pupils have accessed and we do have sanctions and we can and do take internet access away from individuals. The common problems in a school are not just filtering.

You see pupils will open a browser while they should be working in word. They do minimise said browser when Teacher walks past. Pupils will bully others into giving password details (for net access) so sometimes it is hard to sort out the 'wrong doers'. Teacher will want to have internet on sometimes for all a lesson, only half a lesson or last ten minutes of lesson. So taking away individuals access is not an option. For ICT to control this is not an option.

We need a solution that:

We can select either a group of users (a class) or a group of machines (my system does the later) and enables/disables net access.

The teacher needs to control this from their workstation.

Teachers dont need to cut just certain sites out, they need to stop pupils from browsing altogether.

But this has to be done room to room class to class session to session.

Imperata (sanako) was supposed to do this, execept pupils can type a url into word, my computer etc and access internet.

So, the solution ive got may not be ideal and if you want ill post it on the board and you could pick holes in it(it is primative I warn you) but it works. I want the teacher from a form that I write to click a button (after selecting %computername%) and a script run on remote machine that turns off internet access. I could use the Kill udf for closing browsers! (v. useful!).

I hope this explains a schools predicament to you.

I had a quick look at Websense and your right, its not for the school. We can filter/block etc anyway and even produce reports to show what the pupils have been accessing..

Regards

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133170 - 2005-01-31 05:13 PM Re: Running a remote kix script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Rad,
Quote:

the vars will be evaluated before it is sent




Minor detail I overlooked.

One could pull the %windir% from the remote registry.

Stephen,
Instead of setting proxy "per user" it could be set "per machine" which would make it easy to manipulate remotely with a central admin script instead of separate individual local scripts that students can reverse engineer and defeat.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#133171 - 2005-01-31 06:50 PM Re: Running a remote kix script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Also... another item to look at is if you have NoVarInStrings option on in the script.

Try echoing to console what it thinks it will run first to ensure it says what you think it should say.

Top
#133172 - 2005-02-01 09:29 AM Re: Running a remote kix script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Im afraid a proxy isnt the solution




Don't be too quick to disregard it.

The simple solution is to (ask) for the the external proxy that you do not manage to only accept connections from a single IP address. Assign this IP address to an internal proxy server which is under your control.

You now control which users / machines can access the Internet. Either provide the teachers with access to the proxy configuration to allow them to turn rule sets on and off, or configure time-of-day rules to do it automatically if the time-table is sufficiently structured.

Top
#133173 - 2005-02-01 12:49 PM Re: Running a remote kix script
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Hi,

Ive tried using the suggestions made but nothing seems to work. Im assuming that I am using the UDF correctly and replacing $computer in the example with $'mycomputer'. Do I need to install anything else?
Code:
 FUNCTION RemoteExec($command, optional $computer)
dim $Connect, $Process
if not $computer
$computer='.'
endif
if instr($computer,'\')
$computer=substr($computer,instrrev($computer,'\')+1)
endif
$Connect = GetObject('winmgmts:{impersonationLevel=impersonate}!//'+$computer+'/root/cimv2:Win32_Process')
$Process = $Connect.Create($Command)
exit @error
ENDFUNCTION

;copy $folder+'\kix32.exe' $serv2k1+'\c$$\temp'
;copy $folder+'\delprof.kix' $serv2k1+'\c$$\temp'
;RemoteExec('c:\temp\kix32 c:\temp\delprof.kix', $serv2k1)

RemoteExec('kix32.exe c:\winnt\delprof.kix', $serv2k1)



Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#133174 - 2005-02-03 04:37 AM Re: Running a remote kix script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You didn't mention the OS you're running. The UDF requires WMI, thus is limited to Windows 2000/XP unless you install and properly configure WMI for Windows 9x/NT for remote access.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 581 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.073 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org