diff --git a/.gitignore b/.gitignore index 3c4efe2..0eb73fe 100644 --- a/.gitignore +++ b/.gitignore @@ -258,4 +258,6 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc + +!/Headquarters/StartAppBat/PsExec64.exe diff --git a/Headquarters/Scripts/CloseExeClearFolderAndCopyFolder.ps1 b/Headquarters/Scripts/CloseExeClearFolderAndCopyFolder.ps1 new file mode 100644 index 0000000..f8dff57 --- /dev/null +++ b/Headquarters/Scripts/CloseExeClearFolderAndCopyFolder.ps1 @@ -0,0 +1,17 @@ +param($session,$localPath,$remotePath,$exeName) + + +Invoke-Command $session -ScriptBlock { + param($remotePath, $exeName) + $exeInstance = Get-Process $exeName -ErrorAction SilentlyContinue + if ($exeInstance) + { + Stop-Process -Name $exeName -Force + Sleep 2 + } + if(Test-Path $remotePath) + { + Remove-Item $remotePath -Recurse + } +} -ArgumentList ($remotePath, $exeName) +Copy-Item -Recurse -ToSession $session -Path $localPath -Destination $remotePath \ No newline at end of file diff --git a/Headquarters/StartAppBat/PsExec64.exe b/Headquarters/StartAppBat/PsExec64.exe new file mode 100644 index 0000000..9f9ac79 Binary files /dev/null and b/Headquarters/StartAppBat/PsExec64.exe differ diff --git a/Headquarters/StartAppBat/remote.txt b/Headquarters/StartAppBat/remote.txt new file mode 100644 index 0000000..313724f --- /dev/null +++ b/Headquarters/StartAppBat/remote.txt @@ -0,0 +1,2 @@ +192.168.17.128 +192.168.17.129 diff --git a/Headquarters/StartAppBat/start.bat b/Headquarters/StartAppBat/start.bat new file mode 100644 index 0000000..bd48a39 --- /dev/null +++ b/Headquarters/StartAppBat/start.bat @@ -0,0 +1,17 @@ +@echo off +For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set mydate=%%a-%%b-%%c) +For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b) +rem echo %mydate%_%mytime% + +set userName=YourWindowsUserName +set password=YourWindowsPassword +set workingDir=C:\ExeFolderInRemoteMachine +set exePath=C:\ExeFolderInRemoteMachine\ExeToRun.exe +rem log path is case sencitive +set args=-logfile Log\%mydate%_%mytime%.log + +rem Remove following comment to run application +rem .\PsExec64.exe -n 3 -d -i -h -w %workingDir% \\192.168.17.128 -u %userName% -p %password% %exePath% %args% +rem change remote.txt for list of remote machine ip address +.\PsExec64.exe -n 3 -d -i -h -w %workingDir% @remote.txt -u %userName% -p %password% %exePath% %args% +pause