Jump to content

Help with macros @ScriptDir


Recommended Posts

  • Developers

The

6 minutes ago, DirtyJohny said:

C:\Program Files (x86)\DiJo\LOGUS>copy Logus.bat \\2-273-GEMO2\C$

This command is not the same as what you try to do in the script!!!!
Make the whole command exactly the same as what you want to do in the script, so including the path to the script and ensure it is working!

..  and try to post the Source as is without the translation so it remains a valid source!

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Problem may be in the bat file also.

How you start the cmd environment affects stuff.

If you run the batch from another location, working dir will change. You may need to put this line at the beginning of the batch file:

pushd %~dp0

Maybe just remove the /c at the beginning so you can see the cmd window for output.

 

Disclaimer: just woke up, can be halucinating and imagening things 😛

Edited by GokAy
Link to comment
Share on other sites

  • Developers
1 minute ago, DirtyJohny said:

C:\Program Files (x86)\DiJo>copy /y LOGUS\Logus.bat \\2-273-GEMO2\C$

This doesn't contain the RED marked part:

copy / y' & @ScriptDir & '\ LOGUS \ Logus.bat \\' & $ rHostName & '\ C $'

So I expected to see:

C:\Program Files (x86)\DiJo>copy /y c:\the-path\to-the-script\LOGUS\Logus.bat \\2-273-GEMO2\C$

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
2 minutes ago, GokAy said:

Problem may be in the bat file also.

Pretty sure the problem is that the sourcepath contains spaces ....  just taking the steps so the OP will understand why it isn't working. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
1 minute ago, DirtyJohny said:

Dont work I already testing in C:\ , Desktop folder and it doesn't work

Doesn't work means nothing! Show me what doesn't work? 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Ok, what about you stop moving files about and trying something different each time?
So is this now the script directory or not? :  c:\Program Files (x86)\DiJo\LOGUS
And is this the file you want to copy?: Logus.bat

In that case this should be the command: copy /y "c:\Program Files (x86)\DiJo\LOGUS\Logus.bat"  "\\2-273-GEMO2\C$"

3 minutes ago, DirtyJohny said:

I dont want use full path.I know, its working.What you want tell me?Its not working in any path.And exactly its not working for me but how we can do this?

I am totally lost what you mean here, but when you use @scriptpath you are using the full path. Again you have to show me the command you want to perform with AutoIt3 which is working. So do that and we can help you, but you haven't produced that yet!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Okay. I have a program and i need use did her portable(Write in the top).Many files sorted into folders and now process : I write host name and send files,bats,folder links on remote computer.Need shorten the path.

 

Edited by DirtyJohny
Link to comment
Share on other sites

  • Developers

So???  what is the command you want to do?   Including or excluding the full script path?

You really need to start thinking about the correct approach and provide the requested details as I feel like a dentist at this moment! ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

31 minutes ago, GokAy said:

Btw he is trying to copy the bat and not running it right? Disregard my post if so.

PsExec is MS tool to copy what ever you want where ever you want to run it on the target computer after with your local rights. Or you can do domain rights as well. 

So I presume, he want to do a copy file, to copy the bat file to run it with psexec after which is very easy when you know how to run cmd. But anyway the copy is useless because psexec can copy alone. But it should work... 

He do that this way I guess because he want to run the script under other rights.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Yes, about psexec.I need just copy in script folders.Psexec (copy) is not convenient because it has to wait long time for did comand...And i want use copy(@ScriptDir)they fast did comand...excluding the full script path(

 

Edited by DirtyJohny
Link to comment
Share on other sites

This works for me:

Setup: Test files are on R:

image.png.0ded82ab0561e9e71e31160828400e05.png

I can successfully copy "test.bat" to D with this code using double-click starting:

;test comspec.au3

Local $sCMD = @comspec & " /c copy /y """ & @ScriptDir & "\test.bat"" ""d:\"""
Run($sCMD)

However, calling this very script from another script which is on the desktop using Run() doesn't work.

; test comspec from another location.au3

ShellExecute("""R:\test comspec.a3x""") ; OK. this one works, and copies the file
Run("""R:\test comspec.a3x""") ; X. doesn't work

I will leave why to the experts :)

Edit: And this is the au3 version

Run(@AutoItExe & " ""R:\test comspec.au3""") ; Works

Edit2: Added extra double quotes around test.bat path according to Jos' comment below.

Edit3: Hopefully final edit, fixed the string for $sCMD

Edited by GokAy
Added "\" after @ScriptDir, previous one worked because copy location is the root.
Link to comment
Share on other sites

  • Developers
23 minutes ago, GokAy said:

Local $sCMD = @comspec & " /c copy /y " & @ScriptDir & "\test.bat d:\"

Thought I already made a comment about this. ;) 
You really need to put double quotes around the source path since it could contain spaces and I am pretty sure it will fail when that is the case. 

Local $sCMD = @comspec & ' /c copy /y "' & @ScriptDir & '\test.bat" d:\'

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...