Using wmic to start a process on a remote machine as part of a .bat file - windows

TL;DR - I simply want a way to start a powerpoint presentation on a remote machine via command line / batch file using wmic (not PSEXEC).
A litte info...
I am trying to run a process on a remote machine on our network (POWERPNT.EXE). The purpose of this is that we have a .pptx presentation running on a TV in an entrance and this needs updating with info every day. Traditionally this has been done with VNC and simply editing the file but I want to improve this as the screen is part of a multi monitor set up and this can cause issues eslewhere.
So, my batch file will :
Kill the process on the remote machine running the .pptx
Open the file stored on the remote machine's desktop locally in Powerpoint
After saving the presentation in step 2, run the pptx. slide in auto show mode on the remote machine.
I have 1 and 2 working but am struggling to get the final part to run POWERPNT.EXE on the remote.
Here is my code:
wmic /node:"REMOTE-MACHINE-NAME" process call create "C:\Program Files (x86)\Microsoft Office\root\Office16\POWERPNT.EXE /s \\REMOTE-MACHINE-NAME\SHARED-FOLDER\Presentation.pptx"
I don't want to use PSEXEC as not all operators that need to change this slide will have access to that on their PC's.

Related

Is their a way to synchronise a directory on a raspberry pi to a laptop using WinSCP

I want to be able to synchronize a directory between my Windows laptop and raspberry pi using WinSCP. By "synchronize" I mean if a file is created in the directory by my raspberry pi, it is automatically placed in predefined directory on my laptop.
I have already set up a WinSCP connection between these two devices.
I was following along using this tutorial https://www.youtube.com/watch?v=ndvEYOQLc4c however I reliazed that this was for an FTP server and I also could not save the .bat file or code file into the appropriate directory as it has it has an administrator lock, so I assume that the method is only for FTB servers.
Edit
I have given myself permissions to save the code files in the appropriate places, however I now receive the error
Host "lynn-vs2.cloudapp.net" does not exist.
Whenever I run the bat file:
winscp.com /script=SyncToLocalScript.txt
pause
Which in turn runs the txt file:
option batch abort
option confirm off
open sftp://sftpuser04:password123!#lynn-vs2.cloudapp.net -hostkey="ssh-ed25519 256 00:69:55:c8:a8:84:01:6d:7c:ff:9f:8c:89:b3:7d:67"
synchronize local C:\Users\****\OneDrive\Desktop\RaspPCAP /home/pi/Desktop/PCapFiles
exit
I am not sure what "lynn-vs2.cloudapp.net" is.

Open Excel With Batch

I am trying to open an excel file for processing using batch. The code I run on batch is correctly opening the file. The problem is when I try to trigger the same batch file remotely using Jenkins(I have a windows slave). The Jenkins job gets stuck infinitely there after running the command. It does nothing, just shows a message on the screen that says: "A program running on this computer is trying to display a message."[can't post image because of low reputation],
and nothing more.
On clicking view message you get a message that Excel cannot open this file because of the following reasons. which is, i know nothing but a false alarm. How can I modify batch command or Jenkins job or something else on the virtual machine to make the code run?
This is my current command:
"C:\Program Files\Microsoft Office\Office15\EXCEL" /r "C:\file_name.xlsm"
The solution that worked for me was to create a folder named "Desktop" in system32 and SysWow64 (windows 7 64 bit)
C:\Windows\System32\config\systemprofile
C:\Windows\SysWOW64\config\systemprofile
so the full path will be:
C:\Windows\SysWOW64\config\systemprofile\Desktop
C:\Windows\System32\config\systemprofile\Desktop
IIf this doesn't work, you can check the solution by Slav: Open Excel on Jenkins CI.
it pointed me in the right direction

auto run a bat script in windows 7 at login

I have recently acquired a windows 7 laptop from my late grandmother.
I have been using it for work and other things. I decided to create a VM using VirtualBox And now I want to create a user on the (Windows 7 Host) machine so that when I log into that user it autoruns a .bat script to start the VM. To make it clear I only want to run it only if the user "VM" logs in and not my normal user and it would be super awesome if it would autostart in full screen. I have a shortcut on my desktop that executes the command:
"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d- 9cfd-4aa7-8353-20b4e455b3fa"
but how do I make an autorun.bat when I log into the User "VM"?
To run the batch file when the VM user logs in:
Drag the shortcut--the one that's currently on your desktop--(or the batch file itself) to Start - All Programs - Startup. Now when you login as that user, it will launch the batch file.
Another way to do the same thing is to save the shortcut or the batch file in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup\.
As far as getting it to run full screen, it depends a bit what you mean. You can have it launch maximized by editing your batch file like this:
start "" /max "C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d-9cfd-4aa7-8353-20b4e455b3fa"
But if VirtualBox has a truly full-screen mode (where it hides even the taskbar), you'll have to look for a command-line parameter on VirtualBox.exe. I'm not familiar with that product.
I hit this question looking for how to run batch scripts during user logon on a standalone windows server (workgroup not in domain). I found the answer in using group policy.
gpedit.msc
user configuration->administrative templates->system->logon->run these programs at user logon
add batch scripts.
you can add them using cmd /k mybatchfile.cmd if you want the command window to stay (on desktop) after batch script have finished.
gpupdate - to update the group policy.
Just enable parsing of the autoexec.bat in the registry, using these instructions.
:: works only on windows vista and earlier
Run REGEDT32.EXE.
Modify the following value within HKEY_CURRENT_USER:
Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ParseAutoexec
1 = autoexec.bat is parsed
0 = autoexec.bat is not parsed

Net use works in batch file, fails in script

We are a small office with a Linux appliance server (SAMBA) and Win7HP on the desktops. We have one machine that acts as a "backup server" and backs up the server nightly.
Writing what was supposed to be a quick & dirty addition to the backup script that would loop like this:
a. net use * /d /y
b. net use u: \\ourserver\userNN /u:userNN password
c. run sync util to sync u: to this user's storage space on backup server
d. repeat
If I manually create the above in a batch file, everything works fine. (However, for many reasons the procedure must be automated and tied into our existing backup scripts.)
If a script creates the identical batch file and runs it, the first user is logged-in and syncronized, but all subsequent net use attempts fail.
Similarly, if the script attempts to map the drive through code, this message is received:
Unrecognised network error #183
The above error suggests that the network drive/path is unavailable -- but a net use command typed at the command line using identical parameters is successful.
The "backup server" is a Win7HP box with UAC disabled. When cmd prompt is launched, all windows are preceded by the word: Administrator: -- however, when the script launches a command window to net use the drive, the cmd titlebar lacks that prefix.
Any thoughts / ideas?
In order for users to execute this code properly, they will need to have the proper credentials to do so. Also to automate this task, just use Task Scheduler and it should work fine.

How to copy the file from one windows machine to another windows machine in a particular drive using batch script?

In my windows server, am taking SQL DB backup in C drive. I wants to copy this .bak file to some other client windows machine in a particular drive with the current date using batch script. So that i can schedule this batch script using scheduled task. please help me out.
Can anyone, give a script to run this. thanks
Batch files are always tricky to get just right. First I'd open a command line and see if you can copy between two machines using the following syntax:
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
(where "remotemachine" is the name of the remote machine and "c$" is the drive you wish to copy to). You can then copy this into a batch file and set up a scheduled task.
As for renaming the file to have the current date and time, I suggest you start with this question as it may involve some effort to get it into a format you want.

Resources