This article applies to TeamViewer customers with a TeamViewer subscription plan.
- Save time on repetitive tasks by automating your scripts. Upload your batch, PowerShell, or shell scripts encrypted into secure storage within the Management Console.
- During remote sessions, you can select saved scripts from the menu and start the execution with one click.
- Standardize maintenance and support while reducing time to resolution.
- Use your saved time to focus more on important tasks and resolving other support requests.
- Regain your productivity and help more clients along the way.
OneClick remote script execution - Introduction video
Script upload in the TeamViewer Management Console
All scripts that you want to use within a session need to be uploaded in the TeamViewer Management Console encrypted to cloud storage.
Please log in with your TeamViewer account to start.
Prerequisites for the TeamViewer Management Console
There are some preconditions, that you must meet so that you can automate your tasks with scripts. Please make sure that you fulfill them all:
- For script usage, you must have a valid license for TeamViewer 14 (or higher).
- Scripts are ready to use and saved on your local or network folders in a file.
- The script file size is less than 100 kB.
Upload process in the TeamViewer Management Console
You can administer your scripts in the Management Console by clicking the Scripts menu item under Home in the upper left corner.
If you are new to using scripts, you can just start adding a script from the information page with the Add script button.
If you have already uploaded some scripts, they will be displayed in a table.
The Add script button at the top of the table provides a new menu to add some information about the script and to select a script file.
Name and description
You can add a short name and a longer meaningful description for your script. The name will be used for the menu within the session, while the description will be shown as a tooltip for a script menu entry so that you can provide some information about what the script does.
If you do not add any name, the script name (without the file ending) will be taken as default on file selection.
By choosing the operating system only those scripts within the menu in your sessions will be shown, that can be executed on the remote machine operating system you are connected to.
Windows, macOS, and Linux are currently supported.
Run as administrator
If your script uses at least one command, that needs administrative rights (elevated mode on Windows), you should check the Run as administrator execution.
When you start a script, you are asked only once before the start of the execution for permission (if the logged in user already has administrative rights) or for administrator credentials (if the logged in user has no admin rights) regardless of how often or when such commands are used within your script (e.g. for long running tasks).
⚠Currently, you are only able to execute scripts as administrator on an installed TeamViewer. On Windows "Run only (one time use)" option or QuickSupport it is not possible, because the UAC prompt cannot be displayed on the client side.
⚠Scripts in administrative mode are not yet supported for Linux.
The following script types are currently supported
- On Windows
- Batch (.bat, .cmd)
- PowerShell (.ps1)
- On macOS
- On Linux
If you click the Save button, your script file is uploaded encrypted to the cloud storage. Your script data and the link to your script file are also stored encrypted.
You can modify and delete existing scripts by selecting the Edit or Delete function within the context menu for a script item. The context menu is shown if you hover over with the mouse at the end of the table:
If you modify an already existing script file or the script data, the changed file or data is saved instead of the old data. The old script file is deleted from the cloud storage.
Script execution within your sessions
If you start a TeamViewer session, you will have access to your scripts within a new script menu.
There are some prerequisites, that you must meet before you can automate your tasks with scripts. Please make sure that you fulfill them all:
- For script usage, you must have a valid license for TeamViewer 14 (or higher) and installed this version (for Linux TeamViewer 14.2 or higher).
- The remote system you are connected to must have TeamViewer version 14.
- You must be logged in the TeamViewer client with your licensed account (otherwise your scripts will not be displayed for the session).
- The scripts, you want to run on the remote machine, must be marked as suitable for the remote machine operating system.
- For Windows: The TeamViewer client on the remote side must be installed (not started with "Run only"). Otherwise, when running scripts that require administrative rights, the UAC prompt cannot be visible to the connecting client.
- An HTTP connection from the remote system to the cloud storage must be possible.
⚠ Unfortunately, with the new access control for script execution, we had to break compatibility between 14.0/1 and 14.2. To ensure that scripts can be used, make sure that you have either on both sides, client and server, TeamViewer 14.0/14.1 installed or 14.2. A version 14.0/14.1 connecting to 14.2 or vice versa will not work.
Establish a TeamViewer connection after the prerequisites listed above have been met.
- Open the scripts menu.
- Windows: In the client toolbar go to Actions and click the Scripts button to open the menu.
- macOS: In the menu bar go to Scripts.
- All your uploaded scripts for your remote machine operating system will be shown in the displayed menu.
- Select a script to run on the remote machine by clicking on the context menu.
- Once per session: the remote user must accept the script execution request dialogue.
- The script is downloaded to the remote machine from the cloud storage, decrypted and started.
- If the script needs administrative rights, a dialogue will pop up to ask for permission.
- On the remote side, some notifications are shown for the current status.
Permission handling (especially for unattended devices)
⚠The permission setting has changed in 14.2. If you are still using TV 14.0 or 14.1, please see the section below.
Per default, scripts can only be executed if the user on the remote side accepts the execution request. For unattended devices, there is no user, who can acknowledge the request.
For this, you have the possibility in the options/preferences as well as via TeamViewer policies to disable the request dialogue for this TeamViewer installation or to always deny the script execution via a new access control.
It’s not only possible for the incoming session to define the permission but also for the outgoing connections. As this setting can only be changed if you have administrative rights on your computer, this setting can be used to restrict the script execution for non-IT employees of your company.
If you choose an access control, the following defaults are set:
For Custom settings you can define by yourself which value should be used:
The access controls of the local and remote TeamViewer are combined, which means that always the most restricting value of both sides is used.
To check or adapt the permissions on Windows go in the TeamViewer Client to Options > Advanced and then “Advanced settings for connections to this computer” or “Advanced settings for connections to other computers”.
To check or adapt the permissions on macOS go in the TeamViewer Client to the Preferences, select Advanced and then Advanced settings for connections to this computer or Advanced settings for connections to other computers.
To check or adapt the permissions on Linux go in the TeamViewer Client to Options --> Advanced and then Advanced settings for connections to this computer.
You have only the settings for the connections to this computer as starting scripts from a Linux machine is not yet available.
It’s now also possible to role out the settings via the TeamViewer Management Console to multiple devices at once.
Just define your policy in the Management Console and assign it to the devices in your Computers & Contacts list.
- Define your policy under Design & Deploy --> Policies.
- Assign the policy to your devices on Groups > Tools > Assign TeamViewer policies
Permission handling for TeamViewer 14.0 / 14.1
In the options/preferences, you have the possibility to disable the request dialogue for this TeamViewer installation with the setting for Allow script execution without confirmation.
⚠ This setting is no longer available with TV 14.2 and higher. There is no automatic migration done.
On Windows open the TeamViewer client and go to Extras --> Options in the menu. Select the Advanced tab and scroll down to the section Advanced settings for connections to this computer.
On macOS open the TeamViewer client and go to the Preferences in the menu. Select the Advanced tab and scroll down to the section Advanced settings for connections to this computer.
Check the new setting Allow script execution without confirmation and exit with Apply.
Scripts are not available within a session
If you cannot run scripts within a session for some reason, the script menu is shown but is disabled. If you hover over with your mouse, you will find the reason for it in the tooltip that appears.
Tips for writing your scripts
Using '~' for paths on macOS
On macOS you can use ‘~’ to address the user's home directory. If scripts are executed with administrative rights, the script is executed by the root user. Therefore, ‘~’ will be replaced by /var/root and not with the home directory of the logged in user.
Furthermore, the $HOME variable is not set in this case. For these reasons, you should not rely on ‘~’ and $HOME if you run your scripts as administrator.
If you need to create, copy or download folders or files, you can use the working directory of the executed script which is located under ~/Library/Application Support/TeamViewer/Remote Scripting/<script-uuid>.
This directory will be deleted right after the executed script has terminated.
These files and folders are also created by the root user. If necessary you can change the owner with the
chown command and change the rights with
Using the right line endings
It is important, that you are using the right line endings in your script files that can be interpreted by the operating system on which you execute the scripts.
For example, a script file that contains “CR LF” like on Windows cannot be executed on Linux (expects only “LF”).
Why is my PowerShell script not executed on the remote machine but works fine locally?
On Windows the execution of Powershell scripts is restricted per default. You have to change the Execution Policy first.
- On 64-bit machines currently the 32-bit process for the command line is used. For this you have to set the permission on the 32-bit process:
SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe "Set-ExecutionPolicy RemoteSigned".
(This issue will be fixed in a next version, so that the 64-bit process is used.)
For further details, please have a look at the documentation for Get-ExecutionPolicy and Set-ExecutionPolicy