-
Nov 13th, 2014, 11:26 PM
#1
Thread Starter
New Member
psexec in vbscript works fine, except when initiated by drag and drop
I have a vbscript - lets call it "masterscript" that includes a psexec call, something like this:
%comspec% /c psexec.exe -accepteula \\targethostname -u targethostname\username -p password %comspec% /c "cscript \\scriptpath\slavescript.vbs arga argb"
The above command (interpreted for clarity) is put into a variable "cmd", and then called like this:
result = objShell.Run(cmd, 0, FALSE)
Scenario 1:
The above psexec line works perfectly, when I double-click on "masterscript", to run it. In this scenario, I have a popup selection in the middle of masterscript, to choose the text file that contains the variable data I want to use.
Scenario 2:
Then I decided I wanted to instead drag and drop the variable data text file onto "masterscript", in order to initiate the whole execution. Everything appears to work fine with this scheme, except, the above psexec command never actually executes.
If I add "msgbox result" after the result line, it returns "0" in Scenario 1, when I double click masterscript to execute (the scenario where it works). But the result also returns "0" when it doesn't work in Scenario 2, when I drag and drop the variable file onto masterscript, in order to execute.
So I'm guessing, there's some sort of security/permissions issue executing psexec lines, when the script containing them isn't directly initiated (ie. via double-click).
Any ideas how I can get more concrete evidence of what is occurring (I get no errors; it just doesn't issue the psexec command), or how I can get around this?
-
Aug 19th, 2024, 06:07 AM
#2
New Member
Re: psexec in vbscript works fine, except when initiated by drag and drop
Originally Posted by d.armstrong
I have a vbscript - lets call it "masterscript" that includes a psexec call, something like this:
%comspec% /c psexec.exe -accepteula \\targethostname -u targethostname\username -p password %comspec% /c "cscript \\scriptpath\slavescript.vbs arga argb"
The above command (interpreted for clarity) is put into a variable "cmd", and then called like this:
result = objShell.Run(cmd, 0, FALSE)
Scenario 1:
The above psexec line works perfectly, when I double-click on "masterscript", to run it. In this scenario, I have a popup selection in the middle of masterscript, to choose the text file that contains the variable data I want to use.
Scenario 2:
Then I decided I wanted to instead drag and drop the variable data text file onto "masterscript", in order to initiate the whole execution. Everything appears to work fine with this scheme, except, the above psexec command never actually executes.
If I add "msgbox result" after the result line, it returns "0" in Scenario 1, when I double click masterscript to execute (the scenario where it works). But the result also returns "0" when it doesn't work in Scenario 2, when I drag and drop the variable file onto masterscript, in order to execute.
So I'm guessing, there's some sort of security/permissions issue executing psexec lines, when the script containing them isn't directly initiated (ie. via double-click).
Any ideas how I can get more concrete evidence of what is occurring (I get no errors; it just doesn't issue the psexec command), or how I can get around this?
I know this question is ancient, but I registered to VB Forums just to reply in case someone out there has found the answer to this!
I have the EXACT same issue you describe here. My command is:
strCommand = "exiftool """ & "-Directory<FileModifyDate" & """ """ & "-Directory<FileCreateDate" & """ -d """ & strWorkFolder & """/%Y/%m -r """ & strTempExtFolder & """"
It's part of a much bigger script that sorts and organizes photos and videos by the date they were taken. It also encodes the videos with ffmpeg.
All works PERFECTLY when run by double clicking the vbs file, or by debugging in VbsEdit. But if I drag and drop the 'Source' directory (of the photos and videos to process) onto the script, it will fail to execute the command. This is the section that executes the command:
Dim objShell, objExec
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(strCommand)
WScript.Echo ("Executing command: " & strCommand & "...Done.")
Do
WScript.Echo(objExec.StdOut.ReadLine())
Loop While Not objExec.StdOut.AtEndOfStream
WScript.Echo(objExec.StdOut.ReadAll())
Like you, I believe this might be security/permissions related. The script is running from my user accounts 'Documents' folder, exiftool.exe is located in the same directory as the script.
One additional thing to note, I'm calling robocopy in the step just before this, and it works perfectly even if I drag and drop the source folder:
strCommand = "robocopy """ & strTempFolder & """ """ & strTempExtFolder & """ /MOV *." & strExtension
Set objExec = objShell.Exec(strCommand)
Do
WScript.Echo(objExec.StdOut.ReadLine())
Loop While Not objExec.StdOut.AtEndOfStream
WScript.Echo(objExec.StdOut.ReadAll())
Not sure why robocopy works and exiftool fails...
If anyone knows more about this please post!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|