bbimis
asked on
scripting question - move file(s) to folders then create shortcut for all and execute
How could I do this?
I would like to run maybe psexec and send 2 files to EVERYONE on my domain. I want the files to go to the c:\bbi directory on the remote computer(s).
I know i can accomplish this with
But how can i then make it based on on the operating system place a shortcut in the all users startup folder.
My thinking something like this:
Then I need to execute the shortcut on each machine if it isn't already running.
However I can do this would be great. Thanks for the help in advance.
I would like to run maybe psexec and send 2 files to EVERYONE on my domain. I want the files to go to the c:\bbi directory on the remote computer(s).
I know i can accomplish this with
psexec @pc1.txt -u bbi\administrator -p censored cmd.exe /c c:\bbi\exchangefix.exe
then repeat the psexec for the next file.But how can i then make it based on on the operating system place a shortcut in the all users startup folder.
My thinking something like this:
@ECHO OFF
IF EXIST "c:\programdata" (
ECHO FOUND windows 7 machine
COPY /Y \\serverpath\exchangefix_shortcut.lnk "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
IF EXIST "c:\Documents and Settings" (
ECHO FOUND XP machine
Copy /Y \\serverpath\exchangefix_shortcut.lnk "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
ECHO CAN'T DETERMINE MACHINE
Then I need to execute the shortcut on each machine if it isn't already running.
However I can do this would be great. Thanks for the help in advance.
ASKER
here is what I came up with. The experts exchange site went down so i couldn't modify my question. Anyway here is what I have that works. But I need to figure out a way to execute the program if it isn't already running.
here is my push script:
I fire that bat with psexec.
I know I could take and do
my question is how can i make this all in one and also how can i make sure it loaded? like log the process name or something.
I need it to only execute it if not already running.
Thanks!
here is my push script:
@ECHO OFF
IF EXIST "c:\programdata" (
ECHO FOUND Windows 7 Machine
COPY /Y "\\bbifileserv\e\Common\ToTony\Programs I made\fix exchange annoying security popup\*.*" "C:\TONY" 1>NUL 2>NUL
Move /Y "C:\Tony\exchangefix.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
IF EXIST "c:\Documents and Settings" (
ECHO FOUND XP Machine
COPY /Y "\\bbifileserv\e\Common\ToTony\Programs I made\fix exchange annoying security popup\*.*" "C:\Tony" 1>NUL 2>NUL
MOVE /Y "C:\tony\exchangefix.lnk" "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
ECHO CAN NOT DETERMINE SYSTEM
)
)
I fire that bat with psexec.
I know I could take and do
psexec @pcs.txt -u bbi\administrator -p censored \\pathtofilel\pushexchangefix.bat
my question is how can i make this all in one and also how can i make sure it loaded? like log the process name or something.
I need it to only execute it if not already running.
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Best thing to do is let it run from a GPO. To ensure the GPO runs only once, check for a file (i.e. c:\checkfil.txt). Below would be my script for the GPO:
@ECHO OFF
IF EXIST "C:\checkfile.txt" goto End
IF EXIST "c:\programdata" (
ECHO FOUND Windows 7 Machine
COPY /Y "\\bbifileserv\e\Common\To Tony\check file.txt" "C:\" 1>NUL 2>NUL
COPY /Y "\\bbifileserv\e\Common\To Tony\Progr ams I made\fix exchange annoying security popup\*.*" "C:\TONY" 1>NUL 2>NUL
Move /Y "C:\Tony\exchangefix.lnk" "C:\ProgramData\Microsoft\ Windows\St art Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
IF EXIST "c:\Documents and Settings" (
ECHO FOUND XP Machine
COPY /Y "\\bbifileserv\e\Common\To Tony\check file.txt" "C:\" 1>NUL 2>NUL
COPY /Y "\\bbifileserv\e\Common\To Tony\Progr ams I made\fix exchange annoying security popup\*.*" "C:\Tony" 1>NUL 2>NUL
MOVE /Y "C:\tony\exchangefix.lnk" "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
ECHO CAN NOT DETERMINE SYSTEM
)
:End
@ECHO OFF
IF EXIST "C:\checkfile.txt" goto End
IF EXIST "c:\programdata" (
ECHO FOUND Windows 7 Machine
COPY /Y "\\bbifileserv\e\Common\To
COPY /Y "\\bbifileserv\e\Common\To
Move /Y "C:\Tony\exchangefix.lnk" "C:\ProgramData\Microsoft\
) ELSE (
IF EXIST "c:\Documents and Settings" (
ECHO FOUND XP Machine
COPY /Y "\\bbifileserv\e\Common\To
COPY /Y "\\bbifileserv\e\Common\To
MOVE /Y "C:\tony\exchangefix.lnk" "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" 1>NUL 2>NUL
) ELSE (
ECHO CAN NOT DETERMINE SYSTEM
)
:End
ASKER
Thanks that is what I needed
Run SET from the command line to verify on each machine.
Of course using a logon script via GPO may be a more effective way of going about this. :)