0

I work for a application dev company but I am in the support side of it. I am looking to run scripts on to remote-host (logmein Rescue Technician Pro). Our clients all run windows machines and the oldest OS version we support is XP SP3 and the latest win8. I need a scripting language that is native to windows and doesn't require any download this or unzip that. These scripts are Powershell scripts but as we all know the executionpolicy needs to be set to unrestricted. I need a scripting language that automates mouse clicks and keystrokes like hitting enter on the keyboard or typing words into cmd/Powershell, then hitting enter for example. I am trying to run a script in another language to disable the excutionpolicy in Powershell and then start the powershell scripts from this point. I hope I have explained myself.

UPDATE:

I am bad at what I am trying to explain I guess. I need to run a script to disable ExecutionPolicy on remote users through LOGMEIN RESCUE TECHNICIAN. Logmein has a tab called "SCRIPTS" that automatically startup when you connect to the remote session. The problem is that PowerShell by default is set to executionpolicy restricted. That will not allow my scripts to run and I have to run them manually from my machine, I believe their is a way to just run the scripts and have them out put the results to me without having to pull up the remote users GUI, all the computers are their own independent machines and not on a domain. I need to run the scripts as unrestricted on the remote machine on initiation of the remote session. Thats why I having going around in circles trying to figure this out. I was able to disable powershell from the cmd but i need to hit enter, i need to script the enter key stroke but again i keep running into blocks just run my scripts. I'm annoyed by this now at this point.

3 Answers3

1

You can run a powershell script like so:

powershell -executionpolicy unrestricted -file "C:\Myscript.ps1" 

This will not change the global executionpolicy for the whole machine, but just to run that script.

Kevin_
  • 2,916
  • 3
  • 19
  • 18
  • Thanks for the response but I can create my PS script in IES and then deploy it to a remote machine through logmein rescue technician? Doesn't that defeat the security purpose of having -executionpolicy? so scripts can't be ran on the host computer from an unknown source? I need to set it back so no one else can run scripts on the machine also for security purposes but if its that easy, then wow. To make sure I understand executionpolicy can be made to have exceptions to certain scripts? If I can do that then I can just disable the whole execution policy because thats what I need to know. – Tony Chavez Jul 15 '13 at 21:15
  • It only changes the execution policy for that single script. Once the script has ran, it changes back to default (restricted). I'm not familiar with logmein rescue, so I can't help with that aspect of it. – Kevin_ Jul 15 '13 at 21:17
  • Thanks for clearing that up and I am just trying to wrap my head around this – Tony Chavez Jul 16 '13 at 15:40
  • i tried running this and didn't work. I first tried it on my machine local machine and it didn't work. it says PS C:\Windows\system32> C:\Scripts\powershell\callini.ps1 File C:\Scripts\powershell\callini.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details. At line:0 char:0 but when i run this on a remote machine via logmein rescue, it opens up with notepad as the default program. i am back to square 1 on this problem running a ps script on a remote computer. I need to run the script with unrestricted policy – Tony Chavez Jul 22 '13 at 16:43
0

Two options:

1.Stick with PowerShell. When you launch PowerShell, instead of launching from the shortcut, run the following command (either from a cmd prompt, or run command):

powershell.exe -ExecutionPolicy ByPass 

This will run PowerShell with the execution mode set to ByPass.

2.Use the old way of scripting that works on all versions of Windows, VB scripts. (although, after using PowerShell, VB scripts are hard to go back to)

HAL9256
  • 12,384
  • 1
  • 34
  • 46
  • Thanks for the response ok so I can run create this in powershell IES at the start of my script. powershell.exe -ExecutionPolicy ByPass this will then allow me to deploy scripts to the machine but I will need to set it back and that seems like a big security issue if its this easy to disable it or by pass it. Logmein rescue technician has a script button that lets you run scripts when you first start the session. I would need to automate the whole process to save time. thank you for your help – Tony Chavez Jul 15 '13 at 21:18
  • This will launch a PowerShell prompt with the Execution policy set to ByPass. It will not change the Execution policy permanently for the machine. If you need to run a script, @Kevin's post is probably the closest thing to what you want to do. – HAL9256 Jul 15 '13 at 22:52
0

I'd honestly go with JScript (or VBScript, but JScript is a much nicer language IMHO), since you don't want to have to install anything on the remote machines. XP doesn't include PowerShell, so you'd have to install it at some point.

WSH (Windows Scripting Host) languages like VBScript and JScript, and PowerShell can all simulate mouse clicks and keystrokes, but if you want one script that will run on all of those platforms out-of-the-box, you'll need to stick with WSH languages.

If you have any control over what gets installed on the remote systems, though, go with PowerShell, or - at very least - make sure that the Windows Scripting Host components are up to date with the latest release available for the platform. I'm not sure whether that would come as part of the typical Windows Updates or not.

Just my $0.02.

mikekol
  • 1,782
  • 12
  • 14