This post go through steps to run Google Cloud SQL Proxy as Windows Task. Once task is created, it can be triggered to run on windows startup as well.
What is Google Cloud SQL Proxy?
Cloud SQL Auth proxy provides secure access to your instances without a need for Authorized networks or for configuring SSL.
Cloud SQL Auth proxy have the following advantages:
- Secure connections
- Easier connection authorization
- IAM database authentication
Find more information about Cloud SQL Proxy on following Link
https://cloud.google.com/sql/docs/mysql/sql-proxy
Run Cloud SQL Proxy as Windows Task
Step 1 – New Directory
Create Empty Windows Directory (Folder)
C:\CloudProxy\
Step 2 – SQL Proxy Executable
Right-click https://dl.google.com/cloudsql/cloud_sql_proxy_x64.exe and select Save Link As to download the Cloud SQL Auth proxy. Rename the file to cloud_sql_proxy.exe. Place the executable (.exe) file in newly create Folder in Step 1.
Step 3 – .bat File
Paste following command in notepad and save it as a batch file (.bat). Place bat file in Directory created in Step 1
cd C:\CloudProxy\
cloud_sql_proxy -instances=dev-data:us-central1:sql2017=tcp:1425 -credential_file=dev-data-svc.json
Pause
Above command requires instance and credential_file parameters.
Instance: Get Cloud SQL Instance name by going into Google Cloud Console and then into SQL to list all instances. Get Instance Connection Name of the required Instance. Highlighted column in following snapshot contains Instance connection name.

Credential_File: This is the credential file name that contains Google Cloud Service account used for Connection.
Follow this link for steps to generate Service Account Json key File. Service account should have “cloudsql.instances.connect” permissions for a successful connection.
Place Json key file in directory created in Step 1
Step 4 – VBScript
Create VBScript file and Place it in directory created in Step 1. VBScript file should have following commands.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\CloudProxy\cloudSQL.bat" & Chr(34), 0
Set WshShell = Nothing
After Step 4 “C:\CloudProxy\” Directory should have following files.

Step 5 – Scheduler Task
- Open Windows Task Scheduler

- Create a new folder
- Create Basic Task in the new Folder
- Set Trigger as Highlighted Below
- Set Action as below
- Browse to Directory Created in Step 1 and select VBScript File

- Verify Task Details and Finish Setup

New Windows Scheduler Task setup is now completed. This task should start automatically on windows startup.
Note: Account that is running this task should have script execution permissions.
Find below some other useful links
Test sftp connection from windows and linux
Enable Basic Authentication on a Mongo DB