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
psexec @pc1.txt -u bbi\administrator -p censored cmd.exe /c c:\bbi\exchangefix.exe

Open in new window

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
	

Open in new window


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.
bbimisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Giovanni HewardCommented:
Use "%userprofile%\Start Menu" (ran on the end-users machine) for a specific user  and "%allusersprofile%\Start Menu" variable for all users.  Both locations are a junction point which links to the correct location across varying versions of Windows.

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.  :)
0
bbimisAuthor Commented:
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:
@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 
		)
)

Open in new window


I fire that bat with psexec.

I know I could take and do
psexec @pcs.txt -u bbi\administrator -p censored \\pathtofilel\pushexchangefix.bat

Open in new window


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!
0
Giovanni HewardCommented:
Here's an example of how to do that... modify vmware.exe to reflect your process name.

for /f "tokens=1" %%f in ('tasklist^|find "vmware.exe"') do (
     if [%%f]==[vmware.exe] (
          echo %%f resident, exiting...
          goto :eof
     )
)
echo vmware.exe not resident, going hot...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
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\ToTony\checkfile.txt" "C:\" 1>NUL 2>NUL
      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\checkfile.txt" "C:\" 1>NUL 2>NUL
            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
            )
:End
0
bbimisAuthor Commented:
Thanks that is what I needed
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.