Fix the name of the Thunderbird roaming folder by a script - thunderbird

I need to fix the the name of the Users Thunderbird profile folder located in C:\Users\%USERNAME%\AppData\Roaming\Thunderbird.
To do this, I've made a batch script wich changes the xxxxx.default created at the Thunderbird first launch in :
The profiles.ini file
The path of the roaming folder (see below)
All occurrences in prefs.js file
The name of the "Local profile" folder
But even with this, Thunderbird creates another xxxxx.default folder when I start it after running my script.
My question is : why ? What missed I ? Is there another location where I must change the xxxxx.default ?
Thanks

Auto answer :
I had to change the name of the folder located in C:\Users\%USERNAME%\AppData\Roaming\Thunderbird by a name of my choice (mv command).
Then, I created a new profile.ini file with this folder path (echo to a file command). All the rest (prefs.js for example) is made automatically by Thunderbird on the first startup.
1 step : Identify the name of the random directory using DIR command and store it into a variable :
DIR "C:\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles" /ad /b > temp.txt
SET /p PROFIL_FOLDER= < temp.txt
2 step : Change the random folder name :
MV "C:\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles\%PROFILE_FOLDER%" "C:\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles\NEW_DIR"
3 step : Write a new profiles.ini file :
INI_FILE="C:\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles.ini
ECHO [General]>%INI_FILE%
ECHO StartWithLastProfile=^1>>%INI_FILE%
ECHO [Profile0]>>%INI_FILE%
ECHO Name=default>>%INI_FILE%
ECHO IsRelative=^0>>%INI_FILE%
ECHO Path=C:\Users\%USERNAME%\AppData\Roaming\Thunderbird\Profiles\NEW_DIR>>%INI_FILE%
ECHO Default=^1>>%INI_FILE%
All of these is to put in a batch file wich is launched at the startup session.

Related

change directory failing in cmd prompt

I have two files :
perl file "Test.pl" at the location "C:\A1\A11\A12\A13\A14\A15"
bat file "TestBatch.bat" at the loc : "C:\A1\A11\A12\A13\B14"
The perl file "Test.pl" makes a call to the batch file "TestBatch.bat" and then the batch file should try to set the current path to be "C:\A1\A11\" and change the directory to "C:\A1\A11\A12\A13\B14"
But it fails saying the "System cannot find the path specified". I want it to change directory to "C:\A1\A11\A12\A13\B14"
Following is the code of both the files
Test.pl
my $abs_bat_file_loc = "C:\\A1\\A11\\A12\\A13\\B14\\TestBatch.bat";
system ($abs_bat_file_loc);
TestBatch.bat
set current_path=%CD%\..\..\..\..\
cd A12\A13\B14
Note : I ran the perl file in cmd prompt in following way:
cd C:\A1\A11\A12\A13\A14\A15
perl Test.pl
Any help is much appreciated. Thanks in advance!
Instead of
set current_path=%CD%\..\..\..\..\
cd A12\A13\B14
Why not replace it with
PushD %~dp0
this will force the working directory in the batch file to be the full location of where the batch file is located (eg; C:\A1\A11\A12\A13\B14)

Run unity player exe at windows startup automatically

As i have only unity build in exe format how can i put it to the startup of my window so that it run automatically when computer becomes start. Remember I don't want to put it manually is there any scripting ref available to do this or else auto solution?
You can add your application to startup with registry
https://stackoverflow.com/a/14280290/6720987
You can also place it in the windows startup folder
string startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (Directory.GetCurrentDirectory() != startupFolder)
{
string path = Path.Combine(startupFolder, "MyFile.exe");
string ownPath = Assembly.GetExecutingAssembly().Location;
if (File.Exists(path))
{
File.Delete(path);
}
File.Copy(ownPath, path);
}
Beware that almost every virus scanner with see this as malicious
In windows 10 you can do this:
FileUtil.CopyFileOrDirectory("unityProject/mygame.exe", "%userprofile%/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/mygame.exe" );
I want to give my end user an elegant and efficient way to add my exe to Windows startup and here i have managed to provide him batch file in the directory of my exe.
#echo off
Rem This Summary: This batch script will use to add current directories exe file into windows startup folder.
Rem It will work as follow
Rem 1. First search the exe file in the parent directory of this batch file (only one exe should be available next to batch file)
Rem 2. Make its shortcut
Rem 3. paste in sLinkFile(variable name of the location)
set "SCRIPT=%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
::Retriving full path of the .exe which is located in the parent directoy of the batch file(next to batch file)
for %%F in ("%~dp0*.exe") do set "EXEFILE=%%~fF"
> "%SCRIPT%" (
echo Set oWS = WScript.CreateObject^("WScript.Shell"^)
Rem Getting the startup path of the current user
echo sLinkFile = "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Player.lnk"
Rem creating shortcut
echo Set oLink = oWS.CreateShortcut^(sLinkFile^)
Rem target path alread extracted in line 11
echo oLink.TargetPath = "%EXEFILE%"
Rem save the shortcut
echo oLink.Save
)
cscript //NoLogo "%SCRIPT%"
del "%SCRIPT%"
This file will be placed next to my player build and as user will run this batch file a shortcut of my exe will create automatically and added to the startup. So there is no manual work require just a batch file has to run.

Calling Date Modified in CMD

Basically just attempting to create a very basic program that will display the last modified date of a file on our server. Problem is I have no idea how to write it. This is what I attempted
cd \\Server\Folder
msg dir
I also ran into the problem "CMD Does not support UNC Paths as Current Directories" when I tried to change the CD to our servers directory.
What I would like it to do is display in a dialog box the modified date of a "Text.txt" located on our server \\Server\Folder
Any and all help is appreciated
Next .bat script should work:
set "_folder=\\Server\Folder"
set "_filename=Text.txt"
set "_filedatetime=N/A"
pushd %_folder%
for %%G in (%_filename%) do (
rem echo %%~tG %%~fG
if not "%%~tG"=="" set "_filedatetime=%%~tG"
)
popd
echo file %_folder%\%_filename% date and time: %_filedatetime%
Note there is no dialog box in pure cmd command line interpreter, try set /P.
Resources:
SET: Display, set, or remove CMD environment variables
PUSHD, POPD: and UNC Network paths
FOR commands
~ Parameter Extensions

I want to prompt a user for the first 5 characters of a file then have it search for the files

I'm trying to write a script that will prompt the user for the first 5 charters of a file name then have it search the directories for any files that start with that. Then I want it to check to see if a folder is created with the file names and if not create one then move the files there. But if there is a directory for it already then to just move the files too the folder.
Break it down step by step:
"prompt the user for the first 5 characters of a file name" -- you can use the shell read command to get the data. Try a simple shell script:
#!/bin/bash
read foo
echo "foo = $foo"
"if a folder is created with the file names" -- you can use find to see if a file exists. for example:
find . -name abcde\*
"But if there is a directory for it already then to just move the files too the folder." -- the command mkdir takes a -p option so that, if the directory already exists, it won't do anything.

batch file to copy a folder containing the most recently created file

Hey guys,
I'm looking for a batch file which will copy a folder and all its contents containing the most recently created file.
I need it to preserve the folder name at the destination aswell.
For example:
If 'c:\test\source\inhere' contains the most recent file, then i would like the 'inhere' directory and all of its contents copied to the destination, c:\test\destination\inhere.
The .bat file would ideally sit in the 'source' folder in the example above.
Thanks!
xcopy and if exist not exist would do everything you need eg:-
#echo off
xcopy "C:\test\inhere\*.* " c:\mirror\test\inhere\ /c /s /r /d /y /i > c:\mirror\xcopy.log
this would copy from inhere (*.* means any file extensions could be .pdf or whatever) TO
IN HERE in a parent folder called mirror. The xcopy.log just writes a log file so you can check
all was successful