Jump to content

Using with Variables


Recommended Posts

Hi,

I want to know if there are variables for user's desktop, or start menu programs, because I'm using Both English and Greek versions of Windows XP, where these folder names are different.

I also want to know if there is another way to make batch files for copying files in the desktop in both versions, or if I can check with a command the language of windows xp so i can go on with fixed paths.

Thank you for any help

Link to comment
Share on other sites


I don't know, if this helps, but the paths to both are contained in the regkey HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders in the values "desktop" and "start menu".

So in vbs or js you are able to put them in a variable. In a batch, I'm not quit sure, if you can put the value in a variable with the reg query command, but I'm trying to do this, just give me a little time.

Link to comment
Share on other sites

I don't know, if this helps, but the paths to both are contained in the regkey HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders in the values "desktop" and "start menu".

So in vbs or js you are able to put them in a variable. In a batch, I'm not quit sure, if you can put the value in a variable with the reg query command, but I'm trying to do this, just give me a little time.

Maybe this help, I have something similar

@ECHO OFF

:: delims is tab folowed by space

FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\SOFTWARE\id\Doom 3" /v InstallPath') DO SET InstallPath=%%B

ECHO InstallPath=%InstallPath%

COPY .\CRACKOP.txt %InstallPath%

PAUSE

So I can find path in registry but rest of the command dont work. Can anyone correct that part of the command? Why file doesnt get copied in install folder of doom3 (this is just example, I put folder for doom3 because I have that key on my computer contains path to D:\Program files\Doom 3, something similar to problem that you have)

I got Echo reply InstallPath=D:\Program Files\Doom 3 and now I want to copy file to that folder

Link to comment
Share on other sites

Very interesting solution glugorian, I've tried your example and I can find the name of the folder "desktop" for using as a variable.

So I've used this:

@ECHO OFF

:: delims is tab folowed by space

FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Desktop') DO SET Desktop=%%B

ECHO Desktop=%Desktop%

PAUSE

But the variable has the value "Settings\Alex\Desktop", I dont know Why "C:\Documents and" is missing

Thanks for any help

Link to comment
Share on other sites

Ok, I founded, I've just used the tab and the space as you wrote in the comment of the batch file.

Now the variable has the value "c:\documents and settings\alex\desktop"

But I need to use the variable also for all users so I've tried the following:

@ECHO OFF

FOR /F "tokens=2* delims=" %%A IN ('REG QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Common Desktop') DO SET ComDesktop=%%B

ECHO Common Desktop=%ComDesktop%

PAUSE

But I didnt made it, i'm getting an error "Too many command-line parameters".

Also I want to know what is %%A, %%B and if I want 2 or more variables must these letters be changed

Thanks

Link to comment
Share on other sites

Ok, I founded, I've just used the tab and the space as you wrote in the comment of the batch file.

Now the variable has the value "c:\documents and settings\alex\desktop"

But I need to use the variable also for all users so I've tried the following:

@ECHO OFF

FOR /F "tokens=2* delims=" %%A IN ('REG QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Common Desktop') DO SET ComDesktop=%%B

ECHO Common Desktop=%ComDesktop%

PAUSE

But I didnt made it, i'm getting an error "Too many command-line parameters".

Also I want to know what is %%A, %%B and if I want 2 or more variables must these letters be changed

Thanks

Have solution for my problem

@ECHO OFF

:: delims is tab folowed by space

FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\SOFTWARE\id\Doom 3" /v InstallPath') DO SET InstallPath=%%B

ECHO InstallPath=%InstallPath%

COPY .\CRACKOP.txt "%InstallPath%"

IF EXIST "%InstallPath%"\CRACKOP.txt (START .\first.txt GOTO END) ELSE START .\second.cmd

:END

Im not sure what you tried to do. Can you give more details

Edited by glugolian
Link to comment
Share on other sites

I've just want to create variables for desktop and common desktop, because I'm using 2 versions of Windows Greek and English, and the folder names are different.

I've made it with the variable for the desktop, but I cannot make it for Common Desktop as I described.

I'm keeping the ECHO command which is useless for what I do but is the way to check if the variable has the correct value. After this I will delete or copy shortcuts from desktop using these variables.

Edited by g-alex
Link to comment
Share on other sites

You can use the following script to put the path to desktop of the current user into the variable desktop:

@echo off

setlocal enableextensions

for /f "tokens=*" %%a in (

'reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v desktop'

) do (

set myvar=%%a

)

set desktop=%myvar:~15%

echo /%%desktop%%=%desktop%

pause

endlocal

goto :eof

Similarly you can get the other paths, but changing the regkey, which is read.

Link to comment
Share on other sites

Doc Symbiosis, many thanks for your tries to help me

I founded the solution to create variable for the path "C:\Documents and Settings\User\Desktop"

But now I'm trying without success to create a variable for the common desktop "C:\Documents and Settings\All Users\Desktop" see my previous posts.

I think the problem is when I'm trying to get the Value "Common Desktop" from the registry because it has a space.

Thank you very much,

Link to comment
Share on other sites

Ok, I founded, When I used quotes the value was "REG_Z C:\Documents and Settings\All Users\Desktop" and finally I had to remove the space from 'delims' and i left only the tab. So now it is working fine the value is "C:\Documents and Settings\All Users\Desktop"

I wonder what delims is, and why this happened.

Thank you anyway Doc Symbiosis and glugolian, I wouldn't make it without your help.

Edited by g-alex
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...