How can I call a file in a remote server through python3? - python-3.x

For example I have a .py script on my computer (Windows Server 2017), and I want to use it to control a remote server (Windows Server 2017) to do the following steps:
Open MS Word(which has already been installed) on the remote server
Use the word to open a word doc which is located on the remote server too.
Anyone has any brilliant idea? Thanks a lot!

Soo, for this case, i would prefer PowerShell to do this task, because powershell has a lot of libs for admin taks, and automatization. And powershell are the language used in windows server, in my job, i use powershell to do some taks, like send an email, create a profile in the server, and other things. Show me the code:
$Filename='C:\HappyBirthdayEd.docx' #set the name and location of the file
$Word=NEW-Object –comobject Word.Application #set the word application
$Document=$Word.documents.open($Filename) #open the document
So, this little block of code open an word file. Just do some changes and i thing can work.
PS.: Sorry my bad english.

Problem solved here: How to connect to a remote Windows machine to execute commands using python?

Related

Open Excel File on Azure VM with Powershell Script Sent from Local Computer

Can someone show how I can open an Excel document and show it visually on an Azure virtual machine using a Powershell script sent from my local machine? I have already figured out how to run Powershell script on the VM through the AzureVM module but am running into the issue of Windows not allowing remote Powershell users to interact with a user interface. Notes:
I have tried PSEXEC with no luck. This may be the way to go, but I have had no luck getting it to actually work.
I am not smart, so please use the most dumbed-down terminology as possible.
My end goal is exactly that stated above - nothing more nothing less.
Riches and honor to the one who can solve this.

Running .ktr created in windows on centos 6.5 server

Folks,
I trust all is well.
We have .ktr files that are created in widows 7 that we need to run on a centos 6.5 server using pan.
I am trying to run the following command the server:
[root#BTNYSLDVD01 data-integration]# /home/pentaho/data-integration/pan.sh /file=/home/pentaho/data-integration/file.ktr
However I am getting the following error:
2015/10/07 13:03:28 - File Output.0 - Access denied for user 'root'#'localhost' (using password: YES)
The file.ktr file was created and runs properly without errors on a widows 7 computer. The only modification I made was that I altered the <server></server> tag from <server>ip address</server> to <server>localhost</server>
I know that the password is correct because I am able to connect to the database from console.
We cannot create the .ktr files on the centos server since we do not have the desktop installed.
My question is "Is there snything special we need to do when running a .ktr file that was created in windows 7 on a centos 6.5 server"?
Thanks in advance for your help.
Andy
First run this
cd data-integration
chmod +x *.sh
It will make the shell scripts executable.
Without more details, it's hard to know what is wrong.
I guess that you may have a problem of access via ssh : maybe you should have a key (e.g. generated via ssh-keygen) for the user root?
It gets pretty interesting. I find out on page
http://dev.mysql.com/doc/refman/5.6/en/can-not-connect-to-server.html
"A Unix socket file is used if you do not specify a host name or if you specify the special host name localhost."
Unix socket pretty special feature not available on Windows, but Kettle is written on Java which suppose to work on different OS, and can't use Unix socket since it's plafrorm specific. It has to use tcp/ip connection.
Against it, mysql command is platform specific and able to utilize power of Unix socket, since it native tool.
Just try to put 127.0.0.1 instead of localhost
We were able to solve the issue. The issue was that mysql did not allow access from 127.0.0.1. We deployed pentaho on another server and were able to get the file to work. Thanks Simar for all your help.

Run a batch file on a remote desktop from VBA

I am new and seeking help. I manually open a remote desktop to a server and run a batch file I have sitting on that desktop. I want to do this thru VBA. I don't want to see the remote desktop and I would like to know when the batch file is finished running. Here is the code I have found so far. It brings me to the password screen for the remote desktop and I must take it from there manually. What do I need to add to the code to get this done.
TestVar = Shell("C:\windows\system32\mstsc.exe /v:" & "IP Address", 1)
The path for the batch file on the remote is: "C:\users\path\desktop\batch.bat"
If you aren't worried about the logon screen, and want to execute commandfs remotely, you need to take a look at Windows PowerShell
MS Technet - PowerShell INVOKE Command to execute a script on one or more remote computers
MS Technet - Running Remote Commands with PowerShell
I think this immensely popular StackOverFlow topic could prove useful too (See the answer with 200 upvotes by Jason R. Coombs
Stack Overflow: how to use ssh to run shell script on a remote machine

run sharepoint powershell from c# on another PC?

If the C# application is on the same server as sharepoint, I know we can use RunSpace to run the pwoershell script, but what if the C# app. and sharepoint server are on different PCs?
Is this possible?
thanks
yes, its possible, though messy. In Powershell 2.0+, there's a feature called remote powershell, so you can effectively, via c# code, send Powershell commands to your local powershell instance, and use that to log into the remote instance.
A slightly less insane idea would be to simply create a web service on the remote machine, and have that run the remote powershell commands, from the web service.
And even less crazy idea is just to write a web service, and have that run code on the remote server. : )
Good luck!
If you are administrator on the remote box, you can try combining PsExec and PowerShell.

Run a vbscript under an IIS application

I have a vbs file that runs fine and I want to run it under an IIS7 application name. Can this be done? If so, how?
thanks
You could look under "Handler Mappings" in IIS and add one similar to ASP which is how I used to run VBScript on the server side years ago. This does imply that the file is on a web server and you are OK with HTML output of the result.
Just for fun, I was wondering how to do this. I found an article on the Microsoft support site which told me this was possible at one time. As of IIS 7.5 this is even easier than the article suggests. You simply need to create the mapping in IIS:
Steps
Go to the IIS configuration and select the site you'd like to use
VBS files with.
Go to the Handler Mappings configuration for that site.
Click Add Script Map... on the right hand side.
Set the Request Path to *.vbs
Set the Executable to "C:\Windows\System32\cscript.exe" //NOLOGO %s %s
Set the Name to something you'll remember if you need to.
Restart IIS (possibly optional but I did this)
Then, test it with a script such as the following:
WScript.Echo "Content-Type: text/html"
WScript.Echo
WScript.Echo "If you see this, it worked."
Save it as test.vbs in your site and go to the URL to see the results. Every script used this way must begin output with the first two lines of this script or IIS will not use it.
Note: I also have the CGI (from the Windows installation disk) and Fast-CGI (from the Windows download center) modules installed. I'm not sure whether either of these are actually needed though.

Resources