Sign in to follow this  
Followers 0
johnmcloud

[Solved] Folder name with *.* in cmd

6 posts in this topic

#1 ·  Posted (edited)

Hi guys, i need you help, again :D

I have a folder that changes everytime the name. Basically is:

test-test-123456789

The name test-test is equal everytime, the number 123456789 changes.

The problem is this: i have to use cmd for build a file in this directory. It's a simple script to avoid the MAX_LENGHT of cmd ( max 256 character limit )

The directory is:

@workingdir & "\test-test-123456789\build\test.sln

This is the script:

$var1 = "cd Windows\Microsoft.NET\Framework\v4.0.30319"
$var2 =
$var3 = @WorkingDir & $var2 & "\build\test.sln"
Run(@ComSpec)
Send(".cd C:\")
Send("{ENTER}")
Send($var1)
Send("{ENTER}")
Send($var3)

I don't know how to set $var2, because the name changes everytime.

I have also the same problem with directory of Framework ( v4.0.30319 ), but if i know how to set the variable for test-test i can apply for .NET directory

Thanks for support

Edited by johnmcloud

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Opt("ExpandEnvStrings", 1)    ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1)    ;0=don't expand, 1=do expand
Run(@ComSpec)
winwaitactive("[class:ConsoleWindowClass]")
; change to frameworkdir
Send("cd %windir%Microsoft.NETFrameworkv{Tab}{ENTER}")
sleep (3000)
; change to test-test-dir
Send("cd @WorkingDir@test-test-{Tab}{ENTER}")
Send("cd buildtest.sln{ENTER}")

Edited by forumer100

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Opt("ExpandEnvStrings", 1)    ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1)    ;0=don't expand, 1=do expand
Run(@ComSpec)
winwaitactive("[class:ConsoleWindowClass]")
; change to frameworkdir
Send("cd %windir%Microsoft.NETFrameworkv{Tab}{ENTER}")
sleep (3000)
; change to test-test-dir
Send("cd @WorkingDirtest-test-{Tab}{ENTER}")
Send("cd buildtest.sln{ENTER}")

Thanks for answer, the first part work fine :D

But the second not, because it will be:

C:WINDOWSMicrosoft.NETFrameworkv4.0.30319>MSBuild C:Documents and SettingsWindows XpDesktoptest-test-ffd119cbuildtest.sh

I need only 1 line, if you can help i'll be grateful

Edited by johnmcloud

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'll update the script:

Opt("TrayIconHide", 1)
Opt("ExpandEnvStrings", 1)  ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1)  ;0=don't expand, 1=do expand

$var1 = "test-test-ffd119c"
$var2 = "MSBuild" & " " & @WorkingDir & $var1 & "buildtest.sln"
Run(@ComSpec)
winwaitactive("[class:ConsoleWindowClass]")
Send("cd %windir%Microsoft.NETFrameworkv{Tab}{ENTER}")
Send($var2)

Work, but i need to set the variable for part "ffd119c" becouse it changes every update.

How to set this variable?

Edited by johnmcloud

Share this post


Link to post
Share on other sites

Opt("ExpandEnvStrings", 1)    ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 1)    ;0=don't expand, 1=do expand
Run(@ComSpec)
winwaitactive("[class:ConsoleWindowClass]")
; change to test-test dir
Send('cd "@DesktopDir@test-test-"{Tab}{ENTER}')
Send("cd build{ENTER}")
; remember test-test dir
Send("set MyDir=%cd%{ENTER}")
; change to frameworkdir
Send("cd %windir%Microsoft.NETFrameworkv{Tab}{ENTER}")
; call MSBuild
Send("MSBuild %MyDir%test.sh{ENTER}")


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Thanks forumer100, great idea use %MyDir%

Work perfect

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • luckyluke
      By luckyluke
      Hello,
      Im trying to read the output from CMD using Dllcall, here is my code:
      #include <WinAPI.au3> #include <array.au3> Global Const $STD_OUTPUT_HANDLE = -11 Global Const $_CONSOLE_SCREEN_BUFFER_INFO = _ "struct;int dwSizeX;" & _ "short dwSizeY;" & _ "short dwCursorPositionX;" & _ "short dwCursorPositionY;" & _ "short wAttributes;" & _ "short Left;" & _ "short Top;" & _ "short Right;" & _ "short Bottom;" & _ "short dwMaximumWindowSizeX;" & _ "short dwMaximumWindowSizeY;endstruct" $pCmd = Run( "cmd.exe" ) Sleep(1000) $hCmd = WinGetHandle("") ConsoleWrite('handle:' & $hCmd & @CRLF) $aRet = DllCall("kernel32.dll", "int", "AttachConsole", "dword", $pCmd) ;_ArrayDisplay($aRet) If $aRet[0] <> 0 Then $vHandle_data='' $vHandle='' $vHandle_data = DllStructCreate($_CONSOLE_SCREEN_BUFFER_INFO) ; Screen Buffer structure $aRet1 = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) if not @error Then $vHandle = $aRet1[0] $aRet = DllCall("kernel32.dll", "int", "GetConsoleScreenBufferInfo", "hwnd", $vHandle, _ "ptr", $vHandle_data) MsgBox(0, '1',DllStructGetData($vHandle_data, 'dwSizeX') & _WinAPI_GetLastErrorMessage()) EndIf It did not work, i got the message 'The handle is invalid'. Please help?
      Thank you in advance!
    • mihaijulien
      By mihaijulien
      Hello,
      I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns  the following error:  
      Error: array variable has incorrect number of subscripts or subscript dimension range exceeded  
    • fosil
      By fosil
      Hi everyone.

      I'm currently working a program that constantly prints out log files through "consolewrite" and the "#AutoIt3Wrapper_Change2CUI=y" wrapper.

      Part of this program requires me to run a batch script.

      My issue is the batch script launches from the same window as consolewrite. I need the batch file to be launched through a different window as currently this causes an issue with the logs (which need to be very precise) but also causes the batch file to produce some funny behavior...

      Does anyone know how I can force the file to run on a second DOS window?

      Thanks in advance!!!
       
      Edit: Im using the "run" command if that helps. I tried "shellexecute" but that seemed to not launch the batch scripts at all.
    • Baboo85
      By Baboo85
      Hi all,
      I need to start a script that include:
      - admin privileges
      - multiple cmd commands
      - no bat, no exe, no tmp files created anywhere (especially in the user temp folder)
      In a bat file it would be simple, but users shouldn't see what commands I'm sending.
      Example of the script:
      echo off cls echo. echo I AM A TOOL echo. echo NOTE: echo - note 1 echo - note 2 echo - etc set USER1=0 set COMPUTER1=0 if /i %username% equ user.user ( set USER1=1 set COMPUTER1=1 ) if /i %username% equ another.user set USER1=1 if /i %computername% equ notebook set COMPUTER1=1 if %USER1% EQU 1 ( if %COMPUTER1% EQU 1 ( reg delete "HKLM\SOFTWARE\blablabla" /f ) else ( echo Computer not authorized. Contact assistance.) ) else ( echo User not authorized. Contact assistance.) echo. pause exit With the send("") is a disaster.
      I'm a noob here, so what can I do?
       
      EDIT: OR ELSE I explain the situation and what I need, so if there is a simple solution I can use that.
       
      SITUATION: our domain users have Users rights on the machine. Some of them need administrator rights.
      We create a local user with administrator rights, so that the users must insert username and password when asked to run something with administrator rights.
      We have an internal domain group policy that blocks EXE, BAT, COM, TMP files from the user local temp directory, for a security reason (malware). That also blocks most software installation.
      But some users are often out of office, away from workplace and in another country, they need a complete control on their computers.
       
      WHAT I NEED: I need to check the username and the computer name. If the username is the one with local administrator rights and the computer name is a computer that is qualified to temporary remove the policy, then I need to execute a REG DELETE command with administrator rights.
       
      I hope I explained myself.
       
      Thank you very much.
    • TLOTS
      By TLOTS
      Hi!
      I'm triying to get the session id to close automatically a RDP session.
      I tried doing this:
      #RequireAdmin #include <Constants.au3> $DOS = Run('C:\Windows\System32\query.exe user', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'Query User', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ;Run(@ComSpec & " /c " & 'quser', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $Message = StdoutRead($DOS) MsgBox(0,'',$Message) But the $Message is always empty, if I execute any of these commands in a cmd window, it works
      Any idea on why is this falling? there is another way to get this info?
       
      PS: Sorry for my english, i'm not native.