?
Solved

PSEXEC help - execute .bat

Posted on 2007-10-10
8
Medium Priority
?
5,136 Views
Last Modified: 2012-06-27
Hello.
I'm trying to execute a batch file using PSEXEC on a remote system to map shortcuts to the users desktop. The syntax in my .bat is:

echo F|xcopy "F:\Shortcut to Controlled Documents.lnk" "%userprofile%\desktop\Shortcut to Controlled Documents.lnk" /d /y

I know this works. I've used it hundreds of times.

My syntax for PSEXEC is:

PSEXEC @C:\systemlist.txt -c C:\ConDocs.bat

The connection is made but I get an "invalid drive specification" from PSEXEC when attempting to copy the shortcuts. The return shows that it's trying to copy the shortcut to "C:\Documents and Settings\NetworkService\Desktop\Shortcut to Controlled Documents.lnk" and the NetworkService profile has no "desktop" directory.

What I want PSEXEC to do is run the bat file on the current active user that's logged on to the PC. I know I can do this via GPO at the next logon, but I was trying to just get it out of the way without waiting for users to log off/log on again. Can this be done using the %userprofile% wildcard?
0
Comment
Question by:Haze0830
  • 5
7 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 20051854
Certainly should ne as long as they are already logged in.

A batch file might need double  %% not single.

test it.

I hope this helps !
0
 
LVL 2

Author Comment

by:Haze0830
ID: 20053622
That syntax has always worked for me but I'll give it a shot.
0
 
LVL 2

Author Comment

by:Haze0830
ID: 20056793
Well, using two % it's now at least returning the proper user profile. But now I'm getting an error stating "Invalid drive specification". This script works when run from the local PC but NOT when using PSEXEC.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:Haze0830
ID: 20057144
Here's what it returns when using PSEXEC to execute a .bat file, note that in this instance I'm NOT using a profile wildcard and attempting to copy directly to the All Users profile:

C:\Program Files\Support Tools>psexec \\brianlap1 -c C:\condocs.bat

PsExec v1.73 - Execute processes remotely
Copyright (C) 2001-2006 Mark Russinovich
Sysinternals - www.sysinternals.com



'C:\WINDOWS\system32>echo F  | xcopy "F:\Shortcut to Controlled Documents.lnk" "C
:\Documents and Settings\All Users\desktop\Shortcut to Controlled Documents.lnk"
 /d /y
Invalid drive specification
0 File(s) copied
condocs.bat exited on brianlap1 with error code 4.

Here's what it returns when I run PSEXEC with cmd + arguments (ie NO .bat file used):

0
 
LVL 2

Author Comment

by:Haze0830
ID: 20101492
I got this figured out on my own.
0
 
LVL 2

Accepted Solution

by:
Haze0830 earned 0 total points
ID: 20101542
Works with the following syntax:

PSEXEC \\REMOTEPC -U [DOMAIN\USERNAME] -P [PASSWORD] -E -C "\\DIRECTORY\FOLDER\FILE.BAT"
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20135117
Closed, 250 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question