Skip to main content
Add codeblocks.
Source Link
zdan
  • 29.6k
  • 7
  • 62
  • 73

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folderc:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then

c:\temp\myscriptfolder\ 

then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end

copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\ :END %systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1" 

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end

copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from

c:\temp\myscriptfolder\ 

then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\ :END %systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1" 
fixing formatting
Source Link
Adil Hindistan
  • 6.7k
  • 4
  • 29
  • 28

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end copy

copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END %systemroot%\System32\WindowsPowerShell\v1

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END %systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end

copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"

Source Link
Adil Hindistan
  • 6.7k
  • 4
  • 29
  • 28

Well, one way maybe to create a simple batch file that runs your actual script and the first line in that batch file may be to check for existence of a ps1 in your update folder. If there is one, it can copy it down first, and then start your powershell script

Eg. whenever there is an update, you put your 'Mypowershellscript.ps1' script in c:\temp\update\ folder

and let's assume your script will be running from c:\temp\myscriptfolder
then you can create batch file like this

if NOT exist C:\temp\update\mypowershelscript.ps1 goto :end copy /Y c:\temp\update\MyPowerShellScript.ps1 c:\temp\MyScriptFolder\

:END %systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noprofile -file "c:\temp\myscriptfolder\mypowershellscript.ps1"